2006-05-15 Eric Seidel <eseidel@apple.com>
Reviewed by hyatt.
Split css_valueimpl.* and css_ruleimpl.* into separate files (one per class).
http://bugzilla.opendarwin.org/show_bug.cgi?id=8934
* WebCore+SVG/RGBColor.cpp:
(WebCore::RGBColor::RGBColor):
* WebCore.vcproj/WebCore/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/kjs_css.cpp:
(KJS::DOMCSSRule::classInfo):
* bindings/js/kjs_css.h:
* bindings/js/kjs_dom.cpp:
* bindings/js/kjs_html.cpp:
* bindings/js/kjs_window.cpp:
* bindings/objc/DOMCSS.mm:
* bindings/scripts/CodeGeneratorJS.pm:
* css/CSSBorderImageValue.cpp: Added.
(WebCore::CSSBorderImageValue::CSSBorderImageValue):
* css/CSSBorderImageValue.h: Added.
* css/CSSCharsetRule.h: Added.
(WebCore::CSSCharsetRule::CSSCharsetRule):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForShadow):
(WebCore::):
* css/CSSComputedStyleDeclaration.h:
* css/CSSFontFaceRule.cpp: Added.
(WebCore::CSSFontFaceRule::CSSFontFaceRule):
* css/CSSFontFaceRule.h: Added.
(WebCore::CSSFontFaceRule::isFontFaceRule):
* css/CSSGrammar.y:
* css/CSSImageValue.cpp: Added.
(WebCore::CSSImageValue::CSSImageValue):
* css/CSSImageValue.h: Added.
* css/CSSImportRule.cpp: Added.
* css/CSSImportRule.h: Added.
* css/CSSInheritedValue.cpp: Added.
* css/CSSInheritedValue.h: Added.
* css/CSSInitialValue.cpp: Added.
* css/CSSInitialValue.h: Added.
* css/CSSMediaRule.cpp: Added.
(WebCore::CSSMediaRule::CSSMediaRule):
(WebCore::CSSMediaRule::~CSSMediaRule):
(WebCore::CSSMediaRule::append):
(WebCore::CSSMediaRule::deleteRule):
(WebCore::CSSMediaRule::cssText):
* css/CSSMediaRule.h: Added.
(WebCore::CSSMediaRule::media):
(WebCore::CSSMediaRule::cssRules):
* css/CSSMutableStyleDeclaration.cpp: Added.
(WebCore::CSSMutableStyleDeclaration::CSSMutableStyleDeclaration):
(WebCore::CSSMutableStyleDeclaration::setChanged):
* css/CSSMutableStyleDeclaration.h: Added.
* css/CSSPageRule.cpp: Added.
(WebCore::CSSPageRule::CSSPageRule):
* css/CSSPageRule.h: Added.
(WebCore::CSSPageRule::isPageRule):
* css/CSSPrimitiveValue.cpp: Added.
* css/CSSPrimitiveValue.h: Added.
* css/CSSProperty.cpp: Added.
(WebCore::CSSProperty::cssText):
* css/CSSProperty.h: Added.
(WebCore::CSSProperty::CSSProperty):
* css/CSSQuirkPrimitiveValue.h: Added.
* css/CSSRule.cpp: Added.
* css/CSSRule.h: Added.
(WebCore::CSSRule::CSSRule):
* css/CSSRuleList.cpp: Added.
(WebCore::CSSRuleList::CSSRuleList):
(WebCore::CSSRuleList::~CSSRuleList):
(WebCore::CSSRuleList::deleteRule):
(WebCore::CSSRuleList::append):
(WebCore::CSSRuleList::insertRule):
* css/CSSRuleList.h: Added.
(WebCore::CSSRuleList::item):
* css/CSSStyleDeclaration.cpp: Added.
(WebCore::CSSStyleDeclaration::CSSStyleDeclaration):
(WebCore::CSSStyleDeclaration::diff):
* css/CSSStyleDeclaration.h: Added.
* css/CSSStyleRule.cpp: Added.
(WebCore::CSSStyleRule::CSSStyleRule):
(WebCore::CSSStyleRule::selectorText):
* css/CSSStyleRule.h: Added.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::ownerRule):
* css/CSSUnknownRule.h: Added.
(WebCore::CSSUnknownRule::CSSUnknownRule):
* css/CSSValue.h: Added.
* css/CSSValueList.cpp: Added.
* css/CSSValueList.h: Added.
* css/Counter.h: Added.
* css/DashboardRegion.h: Added.
* css/FontFamilyValue.cpp: Added.
* css/FontFamilyValue.h: Added.
(WebCore::FontFamilyValue::genericFamilyType):
* css/FontValue.cpp: Added.
(WebCore::FontValue::cssText):
* css/FontValue.h: Added.
* css/MediaList.cpp:
* css/Pair.h: Added.
(WebCore::Pair::~Pair):
* css/RectImpl.h: Added.
(WebCore::RectImpl::~RectImpl):
* css/ShadowValue.cpp: Added.
(WebCore::ShadowValue::ShadowValue):
* css/ShadowValue.h: Added.
* css/css_base.cpp:
* css/css_ruleimpl.cpp: Removed.
* css/css_ruleimpl.h: Removed.
* css/css_valueimpl.cpp: Removed.
* css/css_valueimpl.h: Removed.
* css/cssparser.cpp:
(WebCore::CSSParser::parseColor):
(WebCore::CSSParser::parseFontFamily):
* css/cssstyleselector.cpp:
(WebCore::CSSStyleSelector::locateCousinList):
(WebCore::CSSStyleSelector::checkSelector):
(WebCore::CSSRuleSet::addRulesFromSheet):
(WebCore::CSSStyleSelector::applyProperty):
(WebCore::CSSStyleSelector::mapBackgroundImage):
* css/cssstyleselector.h:
* dom/CSSMappedAttributeDeclaration.h:
(WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):
* dom/Document.cpp:
* editing/ApplyStyleCommand.cpp:
* editing/CompositeEditCommand.h:
* editing/EditCommand.cpp:
* editing/InsertLineBreakCommand.cpp:
(WebCore::InsertLineBreakCommand::doApply):
* editing/InsertLineBreakCommand.h:
* editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::input):
* editing/RemoveCSSPropertyCommand.cpp:
(WebCore::RemoveCSSPropertyCommand::RemoveCSSPropertyCommand):
(WebCore::RemoveCSSPropertyCommand::~RemoveCSSPropertyCommand):
* editing/RemoveCSSPropertyCommand.h:
(WebCore::RemoveCSSPropertyCommand::styleDeclaration):
* html/HTMLBodyElement.cpp:
* html/HTMLElement.cpp:
* html/HTMLScriptElement.h:
* html/HTMLTokenizer.h:
* kcanvas/KCanvasFilters.h:
(WebCore::KCanvasFEColorMatrix::values):
(WebCore::KCanvasFEColorMatrix::setValues):
(WebCore::KCanvasFEConvolveMatrix::kernel):
(WebCore::KCanvasFEConvolveMatrix::setKernel):
* kcanvas/KCanvasPath.h:
* kcanvas/KCanvasTreeDebug.h:
(WebCore::operator<<):
* kcanvas/RenderPath.h:
* ksvg2/css/SVGCSSParser.cpp:
(WebCore::CSSParser::parseSVGValue):
(WebCore::CSSParser::parseSVGStrokeDasharray):
(WebCore::CSSParser::parseSVGPaint):
(WebCore::CSSParser::parseSVGColor):
* ksvg2/css/SVGCSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applySVGProperty):
* ksvg2/css/SVGRenderStyleDefs.h:
* ksvg2/ecma/Ecma.cpp:
* ksvg2/misc/KCanvasRenderingStyle.cpp:
* ksvg2/misc/KCanvasRenderingStyle.h:
* ksvg2/svg/SVGAnimationElement.cpp:
* ksvg2/svg/SVGColor.cpp:
* ksvg2/svg/SVGColor.h:
* ksvg2/svg/SVGCursorElement.h:
* ksvg2/svg/SVGFEColorMatrixElement.cpp:
(SVGFEColorMatrixElement::filterEffect):
* page/DOMWindow.cpp:
* page/Frame.cpp:
* page/FramePrivate.h:
* platform/DeprecatedValueList.h:
* rendering/RenderTextField.cpp:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14407 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/css/CSSBorderImageValue.cpp b/WebCore/css/CSSBorderImageValue.cpp
new file mode 100644
index 0000000..dff511c
--- /dev/null
+++ b/WebCore/css/CSSBorderImageValue.cpp
@@ -0,0 +1,63 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSBorderImageValue.h"
+
+#include "CSSImageValue.h"
+#include "RectImpl.h"
+
+namespace WebCore {
+
+CSSBorderImageValue::CSSBorderImageValue(PassRefPtr<CSSImageValue> image,
+ PassRefPtr<RectImpl> imageRect, int horizontalRule, int verticalRule)
+ : m_image(image)
+ , m_imageSliceRect(imageRect)
+ , m_horizontalSizeRule(horizontalRule)
+ , m_verticalSizeRule(verticalRule)
+{
+}
+
+String CSSBorderImageValue::cssText() const
+{
+ // Image first.
+ String text(m_image->cssText());
+ text += " ";
+
+ // Now the rect, but it isn't really a rect, so we dump manually
+ text += m_imageSliceRect->top()->cssText();
+ text += " ";
+ text += m_imageSliceRect->right()->cssText();
+ text += " ";
+ text += m_imageSliceRect->bottom()->cssText();
+ text += " ";
+ text += m_imageSliceRect->left()->cssText();
+
+ // Now the keywords.
+ text += " ";
+ text += CSSPrimitiveValue(m_horizontalSizeRule).cssText();
+ text += " ";
+ text += CSSPrimitiveValue(m_verticalSizeRule).cssText();
+
+ return text;
+}
+
+}
diff --git a/WebCore/css/CSSBorderImageValue.h b/WebCore/css/CSSBorderImageValue.h
new file mode 100644
index 0000000..a7823a0
--- /dev/null
+++ b/WebCore/css/CSSBorderImageValue.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSBorderImageValue_H
+#define CSSBorderImageValue_H
+
+#include "CSSValue.h"
+
+namespace WebCore {
+
+class CSSImageValue;
+class RectImpl;
+
+class CSSBorderImageValue : public CSSValue
+{
+public:
+ CSSBorderImageValue();
+ CSSBorderImageValue(PassRefPtr<CSSImageValue>, PassRefPtr<RectImpl>, int horizontalRule, int verticalRule);
+
+ virtual String cssText() const;
+
+public:
+ // The border image.
+ RefPtr<CSSImageValue> m_image;
+
+ // These four values are used to make "cuts" in the image. They can be numbers
+ // or percentages.
+ RefPtr<RectImpl> m_imageSliceRect;
+
+ // Values for how to handle the scaling/stretching/tiling of the image slices.
+ int m_horizontalSizeRule; // Rule for how to adjust the widths of the top/middle/bottom
+ int m_verticalSizeRule; // Rule for how to adjust the heights of the left/middle/right
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSCharsetRule.h b/WebCore/css/CSSCharsetRule.h
new file mode 100644
index 0000000..8616c4b
--- /dev/null
+++ b/WebCore/css/CSSCharsetRule.h
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSCharsetRule_H
+#define CSSCharsetRule_H
+
+#include "CSSRule.h"
+
+namespace WebCore {
+
+class CSSCharsetRule : public CSSRule
+{
+public:
+ CSSCharsetRule(StyleBase* parent) : CSSRule(parent) { m_type = CHARSET_RULE; }
+
+ virtual bool isCharsetRule() { return true; }
+ virtual String cssText() const;
+
+ String encoding() const { return m_encoding; }
+ void setEncoding(String _encoding) { m_encoding = _encoding; }
+
+protected:
+ String m_encoding;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp
index 3400e2b..dec0e16 100644
--- a/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -24,11 +24,17 @@
#include "CSSComputedStyleDeclaration.h"
#include "CachedImage.h"
+#include "DashboardRegion.h"
#include "Document.h"
#include "ExceptionCode.h"
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSPrimitiveValue.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
+#include "CSSValueList.h"
+#include "Pair.h"
#include "RenderObject.h"
+#include "ShadowValue.h"
extern WebCore::String getPropertyName(unsigned short id);
@@ -208,16 +214,16 @@
return 0;
}
-static CSSValue* valueForShadow(const ShadowData *shadow)
+static CSSValue* valueForShadow(const ShadowData* shadow)
{
if (!shadow)
return new CSSPrimitiveValue(CSS_VAL_NONE);
- CSSValueList *list = new CSSValueList;
- for (const ShadowData *s = shadow; s; s = s->next) {
- CSSPrimitiveValue *x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX);
- CSSPrimitiveValue *y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX);
- CSSPrimitiveValue *blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX);
- CSSPrimitiveValue *color = new CSSPrimitiveValue(s->color.rgb());
+ CSSValueList* list = new CSSValueList;
+ for (const ShadowData* s = shadow; s; s = s->next) {
+ CSSPrimitiveValue* x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX);
+ CSSPrimitiveValue* y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX);
+ CSSPrimitiveValue* blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX);
+ CSSPrimitiveValue* color = new CSSPrimitiveValue(s->color.rgb());
list->append(new ShadowValue(x, y, blur, color));
}
return list;
@@ -1267,6 +1273,33 @@
return getPropertyName(computedProperties[i]);
}
+// This is the list of properties we want to copy in the copyInheritableProperties() function.
+// It is the intersection of the list of inherited CSS properties and the
+// properties for which we have a computed implementation in this file.
+const int inheritableProperties[] = {
+ CSS_PROP_BORDER_COLLAPSE,
+ CSS_PROP_BORDER_SPACING,
+ CSS_PROP_COLOR,
+ CSS_PROP_FONT_FAMILY,
+ CSS_PROP_FONT_SIZE,
+ CSS_PROP_FONT_STYLE,
+ CSS_PROP_FONT_VARIANT,
+ CSS_PROP_FONT_WEIGHT,
+ CSS_PROP_LETTER_SPACING,
+ CSS_PROP_LINE_HEIGHT,
+ CSS_PROP_TEXT_ALIGN,
+ CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
+ CSS_PROP_TEXT_INDENT,
+ CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST,
+ CSS_PROP_TEXT_TRANSFORM,
+ CSS_PROP_ORPHANS,
+ CSS_PROP_WHITE_SPACE,
+ CSS_PROP_WIDOWS,
+ CSS_PROP_WORD_SPACING,
+};
+
+const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]);
+
PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInheritableProperties() const
{
return copyPropertiesInSet(inheritableProperties, numInheritableProperties);
diff --git a/WebCore/css/CSSComputedStyleDeclaration.h b/WebCore/css/CSSComputedStyleDeclaration.h
index d9b5078..671d684 100644
--- a/WebCore/css/CSSComputedStyleDeclaration.h
+++ b/WebCore/css/CSSComputedStyleDeclaration.h
@@ -23,10 +23,12 @@
#ifndef CSS_COMPUTEDSTYLE_H
#define CSS_COMPUTEDSTYLE_H
-#include "css_valueimpl.h"
+#include "CSSStyleDeclaration.h"
+#include "Node.h"
namespace WebCore {
+class CSSMutableStyleDeclaration;
class CSSProperty;
class RenderObject;
class RenderStyle;
diff --git a/WebCore/css/CSSFontFaceRule.cpp b/WebCore/css/CSSFontFaceRule.cpp
new file mode 100644
index 0000000..9c9cfde
--- /dev/null
+++ b/WebCore/css/CSSFontFaceRule.cpp
@@ -0,0 +1,40 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 "CSSFontFaceRule.h"
+
+#include "CSSMutableStyleDeclaration.h"
+
+namespace WebCore {
+
+CSSFontFaceRule::CSSFontFaceRule(StyleBase* parent)
+ : CSSRule(parent)
+{
+ m_type = FONT_FACE_RULE;
+}
+
+CSSFontFaceRule::~CSSFontFaceRule()
+{
+}
+
+}
diff --git a/WebCore/css/CSSFontFaceRule.h b/WebCore/css/CSSFontFaceRule.h
new file mode 100644
index 0000000..1324a66
--- /dev/null
+++ b/WebCore/css/CSSFontFaceRule.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSFontFaceRule_H
+#define CSSFontFaceRule_H
+
+#include "CSSRule.h"
+
+namespace WebCore {
+
+class CSSMutableStyleDeclaration;
+
+class CSSFontFaceRule : public CSSRule
+{
+public:
+ CSSFontFaceRule(StyleBase* parent);
+ virtual ~CSSFontFaceRule();
+
+ CSSMutableStyleDeclaration* style() const { return m_style.get(); }
+
+ virtual bool isFontFaceRule() { return true; }
+
+protected:
+ RefPtr<CSSMutableStyleDeclaration> m_style;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSGrammar.y b/WebCore/css/CSSGrammar.y
index 9f53919..6f09033 100644
--- a/WebCore/css/CSSGrammar.y
+++ b/WebCore/css/CSSGrammar.y
@@ -24,13 +24,15 @@
#include "config.h"
+#include "CSSMediaRule.h"
+#include "CSSPrimitiveValue.h"
+#include "CSSRule.h"
+#include "CSSRuleList.h"
#include "CSSStyleSheet.h"
#include "Document.h"
#include "HTMLNames.h"
#include "MediaList.h"
#include "PlatformString.h"
-#include "css_ruleimpl.h"
-#include "css_valueimpl.h"
#include "cssparser.h"
#include <assert.h>
#include <stdlib.h>
@@ -120,12 +122,12 @@
%pure_parser
%union {
- CSSRule *rule;
- CSSSelector *selector;
+ CSSRule* rule;
+ CSSSelector* selector;
bool ok;
MediaList *mediaList;
- CSSMediaRule *mediaRule;
- CSSRuleList *ruleList;
+ CSSMediaRule* mediaRule;
+ CSSRuleList* ruleList;
ParseString string;
float val;
int prop_id;
@@ -135,7 +137,7 @@
int i;
char tok;
Value value;
- ValueList *valueList;
+ ValueList* valueList;
}
%{
diff --git a/WebCore/css/CSSImageValue.cpp b/WebCore/css/CSSImageValue.cpp
new file mode 100644
index 0000000..b5d5731
--- /dev/null
+++ b/WebCore/css/CSSImageValue.cpp
@@ -0,0 +1,69 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSImageValue.h"
+
+#include "Cache.h"
+#include "CachedImage.h"
+#include "CSSValueKeywords.h"
+#include "DocLoader.h"
+
+namespace WebCore {
+
+CSSImageValue::CSSImageValue(const String& url, StyleBase* style)
+ : CSSPrimitiveValue(url, CSS_URI)
+ , m_image(0)
+ , m_accessedImage(false)
+{
+}
+
+CSSImageValue::CSSImageValue()
+ : CSSPrimitiveValue(CSS_VAL_NONE)
+ , m_image(0)
+ , m_accessedImage(true)
+{
+}
+
+CSSImageValue::~CSSImageValue()
+{
+ if (m_image)
+ m_image->deref(this);
+}
+
+CachedImage* CSSImageValue::image(DocLoader* loader)
+{
+ if (!m_accessedImage) {
+ m_accessedImage = true;
+
+ if (loader)
+ m_image = loader->requestImage(getStringValue());
+ else
+ m_image = Cache::requestImage(0, getStringValue());
+
+ if (m_image)
+ m_image->ref(this);
+ }
+
+ return m_image;
+}
+
+}
diff --git a/WebCore/css/CSSImageValue.h b/WebCore/css/CSSImageValue.h
new file mode 100644
index 0000000..e775ba8
--- /dev/null
+++ b/WebCore/css/CSSImageValue.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSImageValue_H
+#define CSSImageValue_H
+
+#include "CSSPrimitiveValue.h"
+#include "CachedObjectClient.h"
+
+namespace WebCore {
+
+class DocLoader;
+
+class CSSImageValue : public CSSPrimitiveValue, public CachedObjectClient
+{
+public:
+ CSSImageValue();
+ CSSImageValue(const String& url, StyleBase*);
+ virtual ~CSSImageValue();
+
+ CachedImage* image(DocLoader*);
+
+protected:
+ CachedImage* m_image;
+ bool m_accessedImage;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSImportRule.cpp b/WebCore/css/CSSImportRule.cpp
new file mode 100644
index 0000000..d25b960
--- /dev/null
+++ b/WebCore/css/CSSImportRule.cpp
@@ -0,0 +1,124 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 "CSSImportRule.h"
+
+#include "CachedCSSStyleSheet.h"
+#include "CSSStyleSheet.h"
+#include "DocLoader.h"
+#include "KURL.h"
+#include "MediaList.h"
+
+namespace WebCore {
+
+CSSImportRule::CSSImportRule(StyleBase* parent, const String& href, MediaList* media)
+ : CSSRule(parent)
+ , m_strHref(href)
+ , m_lstMedia(media)
+ , m_cachedSheet(0)
+ , m_loading(false)
+{
+ m_type = IMPORT_RULE;
+
+ if (m_lstMedia)
+ m_lstMedia->setParent(this);
+ else
+ m_lstMedia = new MediaList(this, String());
+}
+
+CSSImportRule::~CSSImportRule()
+{
+ if (m_lstMedia)
+ m_lstMedia->setParent(0);
+ if (m_styleSheet)
+ m_styleSheet->setParent(0);
+ if (m_cachedSheet)
+ m_cachedSheet->deref(this);
+}
+
+void CSSImportRule::setStyleSheet(const String &url, const String &sheet)
+{
+ if (m_styleSheet)
+ m_styleSheet->setParent(0);
+ m_styleSheet = new CSSStyleSheet(this, url);
+
+ CSSStyleSheet *parent = parentStyleSheet();
+ m_styleSheet->parseString(sheet, !parent || parent->useStrictParsing());
+ m_loading = false;
+
+ checkLoaded();
+}
+
+bool CSSImportRule::isLoading() const
+{
+ return m_loading || (m_styleSheet && m_styleSheet->isLoading());
+}
+
+void CSSImportRule::insertedIntoParent()
+{
+ StyleBase* root = this;
+ StyleBase* parent;
+ while ((parent = root->parent()))
+ root = parent;
+ if (!root->isCSSStyleSheet())
+ return;
+ DocLoader* docLoader = static_cast<CSSStyleSheet*>(root)->docLoader();
+ if (!docLoader)
+ return;
+
+ String absHref = m_strHref;
+ CSSStyleSheet* 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;
+
+ // ### pass correct charset here!!
+ m_cachedSheet = docLoader->requestStyleSheet(absHref, DeprecatedString::null);
+ if (m_cachedSheet) {
+ m_loading = true;
+ m_cachedSheet->ref(this);
+ }
+}
+
+String CSSImportRule::cssText() const
+{
+ String result = "@import url(\"";
+ result += m_strHref;
+ result += "\")";
+
+ if (m_lstMedia) {
+ result += " ";
+ result += m_lstMedia->mediaText();
+ }
+ result += ";";
+
+ return result;
+}
+
+}
diff --git a/WebCore/css/CSSImportRule.h b/WebCore/css/CSSImportRule.h
new file mode 100644
index 0000000..078a446
--- /dev/null
+++ b/WebCore/css/CSSImportRule.h
@@ -0,0 +1,64 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSImportRule_H
+#define CSSImportRule_H
+
+#include "CSSRule.h"
+#include "CachedObjectClient.h"
+
+namespace WebCore {
+
+class CachedCSSStyleSheet;
+
+class CSSImportRule : public CSSRule, public CachedObjectClient
+{
+public:
+ CSSImportRule(StyleBase* parent, const String& href, MediaList*);
+ virtual ~CSSImportRule();
+
+ String href() const { return m_strHref; }
+ MediaList* media() const { return m_lstMedia.get(); }
+ CSSStyleSheet* styleSheet() const { return m_styleSheet.get(); }
+
+ virtual bool isImportRule() { return true; }
+ virtual String cssText() const;
+
+ bool isLoading() const;
+
+ // from CachedObjectClient
+ virtual void setStyleSheet(const String& url, const String& sheet);
+
+ virtual void insertedIntoParent();
+
+protected:
+ String m_strHref;
+ RefPtr<MediaList> m_lstMedia;
+ RefPtr<CSSStyleSheet> m_styleSheet;
+ CachedCSSStyleSheet* m_cachedSheet;
+ bool m_loading;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSInheritedValue.cpp b/WebCore/css/CSSInheritedValue.cpp
new file mode 100644
index 0000000..56c0944
--- /dev/null
+++ b/WebCore/css/CSSInheritedValue.cpp
@@ -0,0 +1,37 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSInheritedValue.h"
+
+namespace WebCore {
+
+unsigned short CSSInheritedValue::cssValueType() const
+{
+ return CSS_INHERIT;
+}
+
+String CSSInheritedValue::cssText() const
+{
+ return "inherit";
+}
+
+}
diff --git a/WebCore/css/CSSInheritedValue.h b/WebCore/css/CSSInheritedValue.h
new file mode 100644
index 0000000..828879d
--- /dev/null
+++ b/WebCore/css/CSSInheritedValue.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSInheritedValue_H
+#define CSSInheritedValue_H
+
+#include "CSSValue.h"
+
+namespace WebCore {
+
+class CSSInheritedValue : public CSSValue
+{
+public:
+ virtual unsigned short cssValueType() const;
+ virtual String cssText() const;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSInitialValue.cpp b/WebCore/css/CSSInitialValue.cpp
new file mode 100644
index 0000000..a5e5eec
--- /dev/null
+++ b/WebCore/css/CSSInitialValue.cpp
@@ -0,0 +1,37 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSInitialValue.h"
+
+namespace WebCore {
+
+unsigned short CSSInitialValue::cssValueType() const
+{
+ return CSS_INITIAL;
+}
+
+String CSSInitialValue::cssText() const
+{
+ return "initial";
+}
+
+}
diff --git a/WebCore/css/CSSInitialValue.h b/WebCore/css/CSSInitialValue.h
new file mode 100644
index 0000000..767e6f2
--- /dev/null
+++ b/WebCore/css/CSSInitialValue.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSInitialValue_H
+#define CSSInitialValue_H
+
+#include "CSSValue.h"
+
+namespace WebCore {
+
+class CSSInitialValue : public CSSValue
+{
+public:
+ virtual unsigned short cssValueType() const;
+ virtual String cssText() const;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSMediaRule.cpp b/WebCore/css/CSSMediaRule.cpp
new file mode 100644
index 0000000..0eb2171
--- /dev/null
+++ b/WebCore/css/CSSMediaRule.cpp
@@ -0,0 +1,112 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 "CSSMediaRule.h"
+
+#include "cssparser.h"
+#include "CSSRuleList.h"
+#include "MediaList.h"
+
+namespace WebCore {
+
+CSSMediaRule::CSSMediaRule(StyleBase* parent, MediaList* mediaList, CSSRuleList* ruleList)
+ : CSSRule(parent)
+ , m_lstMedia(mediaList)
+ , m_lstCSSRules(ruleList)
+{
+ m_type = MEDIA_RULE;
+}
+
+CSSMediaRule::CSSMediaRule(StyleBase* parent)
+ : CSSRule(parent)
+ , m_lstMedia(0)
+ , m_lstCSSRules(new CSSRuleList())
+
+{
+ m_type = MEDIA_RULE;
+}
+
+CSSMediaRule::CSSMediaRule(StyleBase* parent, const String &media)
+ : CSSRule(parent)
+ , m_lstMedia(new MediaList(this, media))
+ , m_lstCSSRules(new CSSRuleList())
+{
+ m_type = MEDIA_RULE;
+}
+
+CSSMediaRule::~CSSMediaRule()
+{
+ if (m_lstMedia)
+ m_lstMedia->setParent(0);
+
+ int length = m_lstCSSRules->length();
+ for (int i = 0; i < length; i++)
+ m_lstCSSRules->item(i)->setParent(0);
+}
+
+unsigned CSSMediaRule::append(CSSRule* rule)
+{
+ if (!rule)
+ return 0;
+
+ rule->setParent(this);
+ return m_lstCSSRules->insertRule(rule, m_lstCSSRules->length());
+}
+
+unsigned CSSMediaRule::insertRule(const String& rule, unsigned index)
+{
+ CSSParser p(useStrictParsing());
+ RefPtr<CSSRule> newRule = p.parseRule(parentStyleSheet(), rule);
+ if (!newRule)
+ return 0;
+ newRule->setParent(this);
+ return m_lstCSSRules->insertRule(newRule.get(), index);
+}
+
+void CSSMediaRule::deleteRule(unsigned index)
+{
+ m_lstCSSRules->deleteRule(index);
+}
+
+String CSSMediaRule::cssText() const
+{
+ String result = "@media ";
+ if (m_lstMedia) {
+ result += m_lstMedia->mediaText();
+ result += " ";
+ }
+ result += "{ \n";
+
+ if (m_lstCSSRules) {
+ unsigned len = m_lstCSSRules->length();
+ for (unsigned i = 0; i < len; i++) {
+ result += " ";
+ result += m_lstCSSRules->item(i)->cssText();
+ result += "\n";
+ }
+ }
+
+ result += "}";
+ return result;
+}
+}
diff --git a/WebCore/css/CSSMediaRule.h b/WebCore/css/CSSMediaRule.h
new file mode 100644
index 0000000..d32c1fd
--- /dev/null
+++ b/WebCore/css/CSSMediaRule.h
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSMediaRule_H
+#define CSSMediaRule_H
+
+#include "CSSRule.h"
+
+namespace WebCore {
+
+class CSSRuleList;
+
+class CSSMediaRule : public CSSRule
+{
+public:
+ CSSMediaRule(StyleBase* parent);
+ CSSMediaRule(StyleBase* parent, const String &media);
+ CSSMediaRule(StyleBase* parent, MediaList* mediaList, CSSRuleList* ruleList);
+ virtual ~CSSMediaRule();
+
+ MediaList* media() const { return m_lstMedia.get(); }
+ CSSRuleList* cssRules() { return m_lstCSSRules.get(); }
+
+ unsigned insertRule(const String& rule, unsigned index);
+ void deleteRule(unsigned index);
+
+ virtual bool isMediaRule() { return true; }
+ virtual String cssText() const;
+
+ /* Not part of the DOM */
+ unsigned append(CSSRule* rule);
+
+protected:
+ RefPtr<MediaList> m_lstMedia;
+ RefPtr<CSSRuleList> m_lstCSSRules;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSMutableStyleDeclaration.cpp b/WebCore/css/CSSMutableStyleDeclaration.cpp
new file mode 100644
index 0000000..4b4f416
--- /dev/null
+++ b/WebCore/css/CSSMutableStyleDeclaration.cpp
@@ -0,0 +1,491 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSMutableStyleDeclaration.h"
+
+#include "CSSImageValue.h"
+#include "cssparser.h"
+#include "CSSPropertyNames.h"
+#include "CSSProperty.h"
+#include "CSSStyleSheet.h"
+#include "Document.h"
+#include "ExceptionCode.h"
+#include "Node.h"
+#include "StyledElement.h"
+
+// Not in any header, so just declare it here for now.
+WebCore::String getPropertyName(unsigned short id);
+
+namespace WebCore {
+
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration()
+ : m_node(0)
+{
+}
+
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent)
+ : CSSStyleDeclaration(parent)
+ , m_node(0)
+{
+}
+
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const DeprecatedValueList<CSSProperty>& values)
+ : CSSStyleDeclaration(parent)
+ , m_values(values)
+ , m_node(0)
+{
+ // FIXME: This allows duplicate properties.
+}
+
+CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CSSProperty * const *properties, int numProperties)
+ : CSSStyleDeclaration(parent)
+ , m_node(0)
+{
+ for (int i = 0; i < numProperties; ++i)
+ m_values.append(*properties[i]);
+ // FIXME: This allows duplicate properties.
+}
+
+CSSMutableStyleDeclaration& CSSMutableStyleDeclaration::operator=(const CSSMutableStyleDeclaration& o)
+{
+ // don't attach it to the same node, just leave the current m_node value
+ m_values = o.m_values;
+ return *this;
+}
+
+String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const
+{
+ RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
+ if (value)
+ return value->cssText();
+
+ // Shorthand and 4-values properties
+ switch ( propertyID ) {
+ case CSS_PROP_BACKGROUND_POSITION:
+ {
+ // ## Is this correct? The code in cssparser.cpp is confusing
+ const int properties[2] = { CSS_PROP_BACKGROUND_POSITION_X,
+ CSS_PROP_BACKGROUND_POSITION_Y };
+ return getShortHandValue( properties, 2 );
+ }
+ case CSS_PROP_BACKGROUND:
+ {
+ const int properties[5] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT,
+ CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION,
+ CSS_PROP_BACKGROUND_COLOR };
+ return getShortHandValue( properties, 5 );
+ }
+ case CSS_PROP_BORDER:
+ {
+ const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE,
+ CSS_PROP_BORDER_COLOR };
+ return getShortHandValue( properties, 3 );
+ }
+ case CSS_PROP_BORDER_TOP:
+ {
+ const int properties[3] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_TOP_STYLE,
+ CSS_PROP_BORDER_TOP_COLOR};
+ return getShortHandValue( properties, 3 );
+ }
+ case CSS_PROP_BORDER_RIGHT:
+ {
+ const int properties[3] = { CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_RIGHT_STYLE,
+ CSS_PROP_BORDER_RIGHT_COLOR};
+ return getShortHandValue( properties, 3 );
+ }
+ case CSS_PROP_BORDER_BOTTOM:
+ {
+ const int properties[3] = { CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_BOTTOM_STYLE,
+ CSS_PROP_BORDER_BOTTOM_COLOR};
+ return getShortHandValue( properties, 3 );
+ }
+ case CSS_PROP_BORDER_LEFT:
+ {
+ const int properties[3] = { CSS_PROP_BORDER_LEFT_WIDTH, CSS_PROP_BORDER_LEFT_STYLE,
+ CSS_PROP_BORDER_LEFT_COLOR};
+ return getShortHandValue( properties, 3 );
+ }
+ case CSS_PROP_OUTLINE:
+ {
+ const int properties[3] = { CSS_PROP_OUTLINE_WIDTH, CSS_PROP_OUTLINE_STYLE,
+ CSS_PROP_OUTLINE_COLOR };
+ return getShortHandValue( properties, 3 );
+ }
+ case CSS_PROP_BORDER_COLOR:
+ {
+ const int properties[4] = { CSS_PROP_BORDER_TOP_COLOR, CSS_PROP_BORDER_RIGHT_COLOR,
+ CSS_PROP_BORDER_BOTTOM_COLOR, CSS_PROP_BORDER_LEFT_COLOR };
+ return get4Values( properties );
+ }
+ case CSS_PROP_BORDER_WIDTH:
+ {
+ const int properties[4] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_RIGHT_WIDTH,
+ CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_LEFT_WIDTH };
+ return get4Values( properties );
+ }
+ case CSS_PROP_BORDER_STYLE:
+ {
+ const int properties[4] = { CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_RIGHT_STYLE,
+ CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_LEFT_STYLE };
+ return get4Values( properties );
+ }
+ case CSS_PROP_MARGIN:
+ {
+ const int properties[4] = { CSS_PROP_MARGIN_TOP, CSS_PROP_MARGIN_RIGHT,
+ CSS_PROP_MARGIN_BOTTOM, CSS_PROP_MARGIN_LEFT };
+ return get4Values( properties );
+ }
+ case CSS_PROP_PADDING:
+ {
+ const int properties[4] = { CSS_PROP_PADDING_TOP, CSS_PROP_PADDING_RIGHT,
+ CSS_PROP_PADDING_BOTTOM, CSS_PROP_PADDING_LEFT };
+ return get4Values( properties );
+ }
+ case CSS_PROP_LIST_STYLE:
+ {
+ const int properties[3] = { CSS_PROP_LIST_STYLE_TYPE, CSS_PROP_LIST_STYLE_POSITION,
+ CSS_PROP_LIST_STYLE_IMAGE };
+ return getShortHandValue( properties, 3 );
+ }
+ }
+ return String();
+}
+
+String CSSMutableStyleDeclaration::get4Values( const int* properties ) const
+{
+ String res;
+ for (int i = 0; i < 4; ++i) {
+ if (!isPropertyImplicit(properties[i])) {
+ RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
+ if (!value) // apparently all 4 properties must be specified.
+ return String();
+ if (!res.isNull())
+ res += " ";
+ res += value->cssText();
+ }
+ }
+ return res;
+}
+
+String CSSMutableStyleDeclaration::getShortHandValue( const int* properties, int number ) const
+{
+ String res;
+ for (int i = 0; i < number; ++i) {
+ if (!isPropertyImplicit(properties[i])) {
+ RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
+ if (value) { // TODO provide default value if !value
+ if (!res.isNull())
+ res += " ";
+ res += value->cssText();
+ }
+ }
+ }
+ return res;
+}
+
+PassRefPtr<CSSValue> CSSMutableStyleDeclaration::getPropertyCSSValue(int propertyID) const
+{
+ DeprecatedValueListConstIterator<CSSProperty> end;
+ for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.fromLast(); it != end; --it)
+ if (propertyID == (*it).m_id)
+ return (*it).value();
+ return 0;
+}
+
+String CSSMutableStyleDeclaration::removeProperty(int propertyID, bool notifyChanged, ExceptionCode& ec)
+{
+ ec = 0;
+
+ String value;
+
+ DeprecatedValueListIterator<CSSProperty> end;
+ for (DeprecatedValueListIterator<CSSProperty> it = m_values.fromLast(); it != end; --it)
+ if (propertyID == (*it).m_id) {
+ value = (*it).value()->cssText();
+ m_values.remove(it);
+ if (notifyChanged)
+ setChanged();
+ break;
+ }
+
+ return value;
+}
+
+void CSSMutableStyleDeclaration::clear()
+{
+ m_values.clear();
+ setChanged();
+}
+
+void CSSMutableStyleDeclaration::setChanged()
+{
+ if (m_node) {
+ m_node->setChanged();
+ // FIXME: Ideally, this should be factored better and there
+ // should be a subclass of CSSMutableStyleDeclaration just
+ // for inline style declarations that handles this
+ if (m_node->isStyledElement() && this == static_cast<StyledElement*>(m_node)->inlineStyleDecl())
+ static_cast<StyledElement*>(m_node)->invalidateStyleAttribute();
+ return;
+ }
+
+ // ### quick&dirty hack for KDE 3.0... make this MUCH better! (Dirk)
+ StyleBase* root = this;
+ while (StyleBase *parent = root->parent())
+ root = parent;
+ if (root->isCSSStyleSheet())
+ static_cast<CSSStyleSheet*>(root)->doc()->updateStyleSelector();
+}
+
+bool CSSMutableStyleDeclaration::getPropertyPriority(int propertyID) const
+{
+ DeprecatedValueListConstIterator<CSSProperty> end;
+ for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
+ if (propertyID == (*it).id())
+ return (*it).isImportant();
+ return false;
+}
+
+int CSSMutableStyleDeclaration::getPropertyShorthand(int propertyID) const
+{
+ DeprecatedValueListConstIterator<CSSProperty> end;
+ for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
+ if (propertyID == (*it).id())
+ return (*it).shorthandID();
+ return false;
+}
+
+bool CSSMutableStyleDeclaration::isPropertyImplicit(int propertyID) const
+{
+ DeprecatedValueListConstIterator<CSSProperty> end;
+ for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
+ if (propertyID == (*it).id())
+ return (*it).isImplicit();
+ return false;
+}
+
+void CSSMutableStyleDeclaration::setProperty(int propertyID, const String &value, bool important, ExceptionCode& ec)
+{
+ setProperty(propertyID, value, important, true, ec);
+}
+
+String CSSMutableStyleDeclaration::removeProperty(int propertyID, ExceptionCode& ec)
+{
+ return removeProperty(propertyID, true, ec);
+}
+
+bool CSSMutableStyleDeclaration::setProperty(int propertyID, const String &value, bool important, bool notifyChanged, ExceptionCode& ec)
+{
+ ec = 0;
+
+ removeProperty(propertyID);
+
+ CSSParser parser(useStrictParsing());
+ bool success = parser.parseValue(this, propertyID, value, important);
+ if (!success) {
+ ec = SYNTAX_ERR;
+ } else if (notifyChanged)
+ setChanged();
+ return success;
+}
+
+bool CSSMutableStyleDeclaration::setProperty(int propertyID, int value, bool important, bool notifyChanged)
+{
+ removeProperty(propertyID);
+ m_values.append(CSSProperty(propertyID, new CSSPrimitiveValue(value), important));
+ if (notifyChanged)
+ setChanged();
+ return true;
+}
+
+void CSSMutableStyleDeclaration::setStringProperty(int propertyId, const String &value, CSSPrimitiveValue::UnitTypes type, bool important)
+{
+ removeProperty(propertyId);
+ m_values.append(CSSProperty(propertyId, new CSSPrimitiveValue(value, type), important));
+ setChanged();
+}
+
+void CSSMutableStyleDeclaration::setImageProperty(int propertyId, const String &URL, bool important)
+{
+ removeProperty(propertyId);
+ m_values.append(CSSProperty(propertyId, new CSSImageValue(URL, this), important));
+ setChanged();
+}
+
+void CSSMutableStyleDeclaration::parseDeclaration(const String &styleDeclaration)
+{
+ m_values.clear();
+ CSSParser parser(useStrictParsing());
+ parser.parseDeclaration(this, styleDeclaration);
+ setChanged();
+}
+
+void CSSMutableStyleDeclaration::addParsedProperties(const CSSProperty * const *properties, int numProperties)
+{
+ for (int i = 0; i < numProperties; ++i) {
+ removeProperty(properties[i]->id(), false);
+ m_values.append(*properties[i]);
+ }
+ // FIXME: This probably should have a call to setChanged() if something changed. We may also wish to add
+ // a notifyChanged argument to this function to follow the model of other functions in this class.
+}
+
+void CSSMutableStyleDeclaration::setLengthProperty(int id, const String &value, bool important, bool /* multiLength*/)
+{
+ bool parseMode = useStrictParsing();
+ setStrictParsing(false);
+ setProperty(id, value, important);
+ setStrictParsing(parseMode);
+}
+
+unsigned CSSMutableStyleDeclaration::length() const
+{
+ return m_values.count();
+}
+
+String CSSMutableStyleDeclaration::item(unsigned i) const
+{
+ if (i >= m_values.count())
+ return String();
+ return getPropertyName(m_values[i].id());
+}
+
+String CSSMutableStyleDeclaration::cssText() const
+{
+ String result = "";
+
+ DeprecatedValueListConstIterator<CSSProperty> end;
+ for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
+ result += (*it).cssText();
+
+ return result;
+}
+
+void CSSMutableStyleDeclaration::setCssText(const String& text, ExceptionCode& ec)
+{
+ ec = 0;
+ m_values.clear();
+ CSSParser parser(useStrictParsing());
+ parser.parseDeclaration(this, text);
+ // FIXME: Detect syntax errors and set ec.
+ setChanged();
+}
+
+void CSSMutableStyleDeclaration::merge(CSSMutableStyleDeclaration *other, bool argOverridesOnConflict)
+{
+ DeprecatedValueListConstIterator<CSSProperty> end;
+ for (DeprecatedValueListConstIterator<CSSProperty> it = other->valuesIterator(); it != end; ++it) {
+ const CSSProperty &property = *it;
+ RefPtr<CSSValue> value = getPropertyCSSValue(property.id());
+ if (value) {
+ if (!argOverridesOnConflict)
+ continue;
+ removeProperty(property.id());
+ }
+ m_values.append(property);
+ }
+ // FIXME: This probably should have a call to setChanged() if something changed. We may also wish to add
+ // a notifyChanged argument to this function to follow the model of other functions in this class.
+}
+
+// This is the list of properties we want to copy in the copyInheritableProperties() function.
+// It is the intersection of the list of inherited CSS properties and the
+// properties for which we have a computed implementation in this file.
+const int inheritableProperties[] = {
+ CSS_PROP_BORDER_COLLAPSE,
+ CSS_PROP_BORDER_SPACING,
+ CSS_PROP_COLOR,
+ CSS_PROP_FONT_FAMILY,
+ CSS_PROP_FONT_SIZE,
+ CSS_PROP_FONT_STYLE,
+ CSS_PROP_FONT_VARIANT,
+ CSS_PROP_FONT_WEIGHT,
+ CSS_PROP_LETTER_SPACING,
+ CSS_PROP_LINE_HEIGHT,
+ CSS_PROP_TEXT_ALIGN,
+ CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
+ CSS_PROP_TEXT_INDENT,
+ CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST,
+ CSS_PROP_TEXT_TRANSFORM,
+ CSS_PROP_ORPHANS,
+ CSS_PROP_WHITE_SPACE,
+ CSS_PROP_WIDOWS,
+ CSS_PROP_WORD_SPACING,
+};
+
+const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]);
+
+// This is the list of properties we want to copy in the copyBlockProperties() function.
+// It is the list of CSS properties that apply specially to block-level elements.
+static const int blockProperties[] = {
+ CSS_PROP_ORPHANS,
+ CSS_PROP_OVERFLOW, // This can be also be applied to replaced elements
+ CSS_PROP_PAGE_BREAK_AFTER,
+ CSS_PROP_PAGE_BREAK_BEFORE,
+ CSS_PROP_PAGE_BREAK_INSIDE,
+ CSS_PROP_TEXT_ALIGN,
+ CSS_PROP_TEXT_INDENT,
+ CSS_PROP_WIDOWS
+};
+
+const unsigned numBlockProperties = sizeof(blockProperties) / sizeof(blockProperties[0]);
+
+PassRefPtr<CSSMutableStyleDeclaration> CSSMutableStyleDeclaration::copyBlockProperties() const
+{
+ return copyPropertiesInSet(blockProperties, numBlockProperties);
+}
+
+void CSSMutableStyleDeclaration::removeBlockProperties()
+{
+ removePropertiesInSet(blockProperties, numBlockProperties);
+}
+
+void CSSMutableStyleDeclaration::removeInheritableProperties()
+{
+ removePropertiesInSet(inheritableProperties, numInheritableProperties);
+}
+
+void CSSMutableStyleDeclaration::removePropertiesInSet(const int *set, unsigned length)
+{
+ bool changed = false;
+ for (unsigned i = 0; i < length; i++) {
+ RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
+ if (value) {
+ m_values.remove(CSSProperty(set[i], value.release(), false));
+ changed = true;
+ }
+ }
+ if (changed)
+ setChanged();
+}
+
+PassRefPtr<CSSMutableStyleDeclaration> CSSMutableStyleDeclaration::makeMutable()
+{
+ return this;
+}
+
+PassRefPtr<CSSMutableStyleDeclaration> CSSMutableStyleDeclaration::copy() const
+{
+ return new CSSMutableStyleDeclaration(0, m_values);
+}
+
+}
diff --git a/WebCore/css/CSSMutableStyleDeclaration.h b/WebCore/css/CSSMutableStyleDeclaration.h
new file mode 100644
index 0000000..04b8be3
--- /dev/null
+++ b/WebCore/css/CSSMutableStyleDeclaration.h
@@ -0,0 +1,108 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSMutableStyleDeclaration_H
+#define CSSMutableStyleDeclaration_H
+
+#include "CSSStyleDeclaration.h"
+#include "CSSPrimitiveValue.h" // for CSSPrimitiveValue::UnitTypes
+#include "DeprecatedValueList.h"
+
+namespace WebCore {
+
+class Node;
+
+class CSSMutableStyleDeclaration : public CSSStyleDeclaration
+{
+public:
+ CSSMutableStyleDeclaration();
+ CSSMutableStyleDeclaration(CSSRule* parentRule);
+ CSSMutableStyleDeclaration(CSSRule* parentRule, const DeprecatedValueList<CSSProperty>&);
+ CSSMutableStyleDeclaration(CSSRule* parentRule, const CSSProperty * const *, int numProperties);
+
+ CSSMutableStyleDeclaration &operator=(const CSSMutableStyleDeclaration &);
+
+ void setNode(Node* node) { m_node = node; }
+
+ virtual String cssText() const;
+ virtual void setCssText(const String&, ExceptionCode&);
+
+ virtual unsigned length() const;
+ virtual String item(unsigned index) const;
+
+ virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
+ virtual String getPropertyValue(int propertyID) const;
+ virtual bool getPropertyPriority(int propertyID) const;
+ virtual int getPropertyShorthand(int propertyID) const;
+ virtual bool isPropertyImplicit(int propertyID) const;
+
+ virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
+ virtual String removeProperty(int propertyID, ExceptionCode&);
+
+ virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
+ virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
+
+ DeprecatedValueListConstIterator<CSSProperty> valuesIterator() const { return m_values.begin(); }
+
+ bool setProperty(int propertyID, int value, bool important = false, bool notifyChanged = true);
+ bool setProperty(int propertyID, const String& value, bool important, bool notifyChanged, ExceptionCode&);
+ bool setProperty(int propertyId, const String& value, bool important = false, bool notifyChanged = true)
+ { ExceptionCode ec; return setProperty(propertyId, value, important, notifyChanged, ec); }
+
+ String removeProperty(int propertyID, bool notifyChanged, ExceptionCode&);
+ String removeProperty(int propertyID, bool notifyChanged = true)
+ { ExceptionCode ec; return removeProperty(propertyID, notifyChanged, ec); }
+
+ void clear();
+
+ void setChanged();
+
+ // setLengthProperty treats integers as pixels! (Needed for conversion of HTML attributes.)
+ void setLengthProperty(int propertyId, const String& value, bool important, bool multiLength = false);
+ void setStringProperty(int propertyId, const String& value, CSSPrimitiveValue::UnitTypes, bool important = false); // parsed string value
+ void setImageProperty(int propertyId, const String& URL, bool important = false);
+
+ // The following parses an entire new style declaration.
+ void parseDeclaration(const String& styleDeclaration);
+
+ // Besides adding the properties, this also removes any existing properties with these IDs.
+ // It does no notification since it's called by the parser.
+ void addParsedProperties(const CSSProperty * const *, int numProperties);
+
+ PassRefPtr<CSSMutableStyleDeclaration> copyBlockProperties() const;
+ void removeBlockProperties();
+ void removeInheritableProperties();
+ void removePropertiesInSet(const int* set, unsigned length);
+
+ void merge(CSSMutableStyleDeclaration*, bool argOverridesOnConflict = true);
+
+private:
+ String getShortHandValue(const int* properties, int number) const;
+ String get4Values(const int* properties) const;
+
+ DeprecatedValueList<CSSProperty> m_values;
+ Node* m_node;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSPageRule.cpp b/WebCore/css/CSSPageRule.cpp
new file mode 100644
index 0000000..ec22f3a
--- /dev/null
+++ b/WebCore/css/CSSPageRule.cpp
@@ -0,0 +1,51 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 "CSSPageRule.h"
+
+#include "CSSMutableStyleDeclaration.h"
+
+namespace WebCore {
+
+CSSPageRule::CSSPageRule(StyleBase* parent)
+ : CSSRule(parent)
+{
+ m_type = PAGE_RULE;
+}
+
+CSSPageRule::~CSSPageRule()
+{
+}
+
+String CSSPageRule::selectorText() const
+{
+ // ###
+ return String();
+}
+
+void CSSPageRule::setSelectorText(String /*str*/)
+{
+ // ###
+}
+
+}
diff --git a/WebCore/css/CSSPageRule.h b/WebCore/css/CSSPageRule.h
new file mode 100644
index 0000000..0202729d
--- /dev/null
+++ b/WebCore/css/CSSPageRule.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSPageRule_H
+#define CSSPageRule_H
+
+#include "CSSRule.h"
+
+namespace WebCore {
+
+class CSSMutableStyleDeclaration;
+
+class CSSPageRule : public CSSRule
+{
+public:
+ CSSPageRule(StyleBase* parent);
+ virtual ~CSSPageRule();
+
+ CSSMutableStyleDeclaration* style() const { return m_style.get(); }
+
+ virtual bool isPageRule() { return true; }
+
+ WebCore::String selectorText() const;
+ void setSelectorText(String str);
+
+protected:
+ RefPtr<CSSMutableStyleDeclaration> m_style;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSPrimitiveValue.cpp b/WebCore/css/CSSPrimitiveValue.cpp
new file mode 100644
index 0000000..82c4b50
--- /dev/null
+++ b/WebCore/css/CSSPrimitiveValue.cpp
@@ -0,0 +1,517 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSPrimitiveValue.h"
+
+#include "Color.h"
+#include "Counter.h"
+#include "CSSValueKeywords.h"
+#include "DashboardRegion.h"
+#include "ExceptionCode.h"
+#include "Pair.h"
+#include "render_style.h"
+
+namespace WebCore {
+
+// Quotes the string if it needs quoting.
+// We use single quotes for now beause markup.cpp uses double quotes.
+static String quoteStringIfNeeded(const String &string)
+{
+ // For now, just do this for strings that start with "#" to fix Korean font names that start with "#".
+ // Post-Tiger, we should isLegalIdentifier instead after working out all the ancillary issues.
+ if (string[0] != '#')
+ return string;
+
+ // FIXME: Also need to transform control characters into \ sequences.
+ String s = string;
+ s.replace('\\', "\\\\");
+ s.replace('\'', "\\'");
+ return "'" + s + "'";
+}
+
+CSSPrimitiveValue::CSSPrimitiveValue()
+{
+ m_type = 0;
+}
+
+CSSPrimitiveValue::CSSPrimitiveValue(int ident)
+{
+ m_value.ident = ident;
+ m_type = CSS_IDENT;
+}
+
+CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitTypes type)
+{
+ m_value.num = num;
+ m_type = type;
+}
+
+CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitTypes type)
+{
+ if ((m_value.string = str.impl()))
+ m_value.string->ref();
+ m_type = type;
+}
+
+CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<Counter> c)
+{
+ m_value.counter = c.release();
+ m_type = CSS_COUNTER;
+}
+
+CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<RectImpl> r)
+{
+ m_value.rect = r.release();
+ m_type = CSS_RECT;
+}
+
+#if __APPLE__
+CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<DashboardRegion> r)
+{
+ m_value.region = r.release();
+ m_type = CSS_DASHBOARD_REGION;
+}
+#endif
+
+CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color)
+{
+ m_value.rgbcolor = color;
+ m_type = CSS_RGBCOLOR;
+}
+
+CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<Pair> p)
+{
+ m_value.pair = p.release();
+ m_type = CSS_PAIR;
+}
+
+CSSPrimitiveValue::~CSSPrimitiveValue()
+{
+ cleanup();
+}
+
+void CSSPrimitiveValue::cleanup()
+{
+ switch(m_type) {
+ case CSS_STRING:
+ case CSS_URI:
+ case CSS_ATTR:
+ if (m_value.string)
+ m_value.string->deref();
+ break;
+ case CSS_COUNTER:
+ m_value.counter->deref();
+ break;
+ case CSS_RECT:
+ m_value.rect->deref();
+ break;
+ case CSS_PAIR:
+ m_value.pair->deref();
+ break;
+#if __APPLE__
+ case CSS_DASHBOARD_REGION:
+ if (m_value.region)
+ m_value.region->deref();
+ break;
+#endif
+ default:
+ break;
+ }
+
+ m_type = 0;
+}
+
+int CSSPrimitiveValue::computeLengthInt(RenderStyle *style)
+{
+ double result = computeLengthFloat(style);
+
+ // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
+ // need to go ahead and round if we're really close to the next integer value.
+ result += result < 0 ? -0.01 : +0.01;
+
+ if (result > INT_MAX || result < INT_MIN)
+ return 0;
+ return (int)result;
+}
+
+int CSSPrimitiveValue::computeLengthInt(RenderStyle *style, double multiplier)
+{
+ double result = multiplier * computeLengthFloat(style);
+
+ // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
+ // need to go ahead and round if we're really close to the next integer value.
+ result += result < 0 ? -0.01 : +0.01;
+
+ if (result > INT_MAX || result < INT_MIN)
+ return 0;
+ return (int)result;
+}
+
+const int intMaxForLength = 0x7ffffff; // max value for a 28-bit int
+const int intMinForLength = (-0x7ffffff-1); // min value for a 28-bit int
+
+// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
+int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle *style)
+{
+ double result = computeLengthFloat(style);
+
+ // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
+ // need to go ahead and round if we're really close to the next integer value.
+ result += result < 0 ? -0.01 : +0.01;
+
+ if (result > intMaxForLength || result < intMinForLength)
+ return 0;
+ return (int)result;
+}
+
+// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
+int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle *style, double multiplier)
+{
+ double result = multiplier * computeLengthFloat(style);
+
+ // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
+ // need to go ahead and round if we're really close to the next integer value.
+ result += result < 0 ? -0.01 : +0.01;
+
+ if (result > intMaxForLength || result < intMinForLength)
+ return 0;
+ return (int)result;
+}
+
+short CSSPrimitiveValue::computeLengthShort(RenderStyle *style)
+{
+ double result = computeLengthFloat(style);
+
+ // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
+ // need to go ahead and round if we're really close to the next integer value.
+ result += result < 0 ? -0.01 : +0.01;
+
+ if (result > SHRT_MAX || result < SHRT_MIN)
+ return 0;
+ return (short)result;
+}
+
+short CSSPrimitiveValue::computeLengthShort(RenderStyle *style, double multiplier)
+{
+ double result = multiplier * computeLengthFloat(style);
+
+ // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
+ // need to go ahead and round if we're really close to the next integer value.
+ result += result < 0 ? -0.01 : +0.01;
+
+ if (result > SHRT_MAX || result < SHRT_MIN)
+ return 0;
+ return (short)result;
+}
+
+double CSSPrimitiveValue::computeLengthFloat(RenderStyle *style, bool applyZoomFactor)
+{
+ unsigned short type = primitiveType();
+
+ // We always assume 96 CSS pixels in a CSS inch. This is the cold hard truth of the Web.
+ // At high DPI, we may scale a CSS pixel, but the ratio of the CSS pixel to the so-called
+ // "absolute" CSS length units like inch and pt is always fixed and never changes.
+ double cssPixelsPerInch = 96.;
+
+ double factor = 1.;
+ switch(type) {
+ case CSS_EMS:
+ factor = applyZoomFactor ?
+ style->fontDescription().computedSize() :
+ style->fontDescription().specifiedSize();
+ break;
+ case CSS_EXS: {
+ // FIXME: We have a bug right now where the zoom will be applied multiple times to EX units.
+ // We really need to compute EX using fontMetrics for the original specifiedSize and not use
+ // our actual constructed rendering font.
+ factor = style->font().xHeight();
+ break;
+ }
+ case CSS_PX:
+ break;
+ case CSS_CM:
+ factor = cssPixelsPerInch/2.54; // (2.54 cm/in)
+ break;
+ case CSS_MM:
+ factor = cssPixelsPerInch/25.4;
+ break;
+ case CSS_IN:
+ factor = cssPixelsPerInch;
+ break;
+ case CSS_PT:
+ factor = cssPixelsPerInch/72.;
+ break;
+ case CSS_PC:
+ // 1 pc == 12 pt
+ factor = cssPixelsPerInch*12./72.;
+ break;
+ default:
+ return -1;
+ }
+
+ return getFloatValue() * factor;
+}
+
+void CSSPrimitiveValue::setFloatValue( unsigned short unitType, double floatValue, ExceptionCode& ec)
+{
+ ec = 0;
+ cleanup();
+ // ### check if property supports this type
+ if (m_type > CSS_DIMENSION) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+ //if(m_type > CSS_DIMENSION) throw DOMException(INVALID_ACCESS_ERR);
+ m_value.num = floatValue;
+ m_type = unitType;
+}
+
+double scaleFactorForConversion(unsigned short unitType)
+{
+ double cssPixelsPerInch = 96.0;
+ double factor = 1.0;
+
+ switch(unitType) {
+ case CSSPrimitiveValue::CSS_PX:
+ break;
+ case CSSPrimitiveValue::CSS_CM:
+ factor = cssPixelsPerInch / 2.54; // (2.54 cm/in)
+ break;
+ case CSSPrimitiveValue::CSS_MM:
+ factor = cssPixelsPerInch / 25.4;
+ break;
+ case CSSPrimitiveValue::CSS_IN:
+ factor = cssPixelsPerInch;
+ break;
+ case CSSPrimitiveValue::CSS_PT:
+ factor = cssPixelsPerInch / 72.0;
+ break;
+ case CSSPrimitiveValue::CSS_PC:
+ factor = cssPixelsPerInch * 12.0 / 72.0; // 1 pc == 12 pt
+ break;
+ default:
+ break;
+ }
+
+ return factor;
+}
+
+double CSSPrimitiveValue::getFloatValue(unsigned short unitType)
+{
+ if (unitType == m_type || unitType < CSS_PX || unitType > CSS_PC)
+ return m_value.num;
+
+ double convertedValue = m_value.num;
+
+ // First convert the value from m_type into CSSPixels
+ double factor = scaleFactorForConversion(m_type);
+ convertedValue *= factor;
+
+ // Now convert from CSSPixels to the specified unitType
+ factor = scaleFactorForConversion(unitType);
+ convertedValue /= factor;
+
+ return convertedValue;
+}
+
+void CSSPrimitiveValue::setStringValue( unsigned short stringType, const String &stringValue, ExceptionCode& ec)
+{
+ ec = 0;
+ cleanup();
+ //if(m_type < CSS_STRING) throw DOMException(INVALID_ACCESS_ERR);
+ //if(m_type > CSS_ATTR) throw DOMException(INVALID_ACCESS_ERR);
+ if (m_type < CSS_STRING || m_type > CSS_ATTR) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+ if (stringType != CSS_IDENT) {
+ m_value.string = stringValue.impl();
+ m_value.string->ref();
+ m_type = stringType;
+ }
+ // ### parse ident
+}
+
+String CSSPrimitiveValue::getStringValue() const
+{
+ switch (m_type) {
+ case CSS_STRING:
+ case CSS_ATTR:
+ case CSS_URI:
+ return m_value.string;
+ case CSS_IDENT:
+ return getValueName(m_value.ident);
+ default:
+ // FIXME: The CSS 2.1 spec says you should throw an exception here.
+ break;
+ }
+
+ return String();
+}
+
+unsigned short CSSPrimitiveValue::cssValueType() const
+{
+ return CSS_PRIMITIVE_VALUE;
+}
+
+bool CSSPrimitiveValue::parseString( const String &/*string*/, bool )
+{
+ // ###
+ return false;
+}
+
+int CSSPrimitiveValue::getIdent()
+{
+ if(m_type != CSS_IDENT) return 0;
+ return m_value.ident;
+}
+
+String CSSPrimitiveValue::cssText() const
+{
+ // ### return the original value instead of a generated one (e.g. color
+ // name if it was specified) - check what spec says about this
+ String text;
+ switch ( m_type ) {
+ case CSS_UNKNOWN:
+ // ###
+ break;
+ case CSS_NUMBER:
+ text = String::number(m_value.num);
+ break;
+ case CSS_PERCENTAGE:
+ text = String::number(m_value.num) + "%";
+ break;
+ case CSS_EMS:
+ text = String::number(m_value.num) + "em";
+ break;
+ case CSS_EXS:
+ text = String::number(m_value.num) + "ex";
+ break;
+ case CSS_PX:
+ text = String::number(m_value.num) + "px";
+ break;
+ case CSS_CM:
+ text = String::number(m_value.num) + "cm";
+ break;
+ case CSS_MM:
+ text = String::number(m_value.num) + "mm";
+ break;
+ case CSS_IN:
+ text = String::number(m_value.num) + "in";
+ break;
+ case CSS_PT:
+ text = String::number(m_value.num) + "pt";
+ break;
+ case CSS_PC:
+ text = String::number(m_value.num) + "pc";
+ break;
+ case CSS_DEG:
+ text = String::number(m_value.num) + "deg";
+ break;
+ case CSS_RAD:
+ text = String::number(m_value.num) + "rad";
+ break;
+ case CSS_GRAD:
+ text = String::number(m_value.num) + "grad";
+ break;
+ case CSS_MS:
+ text = String::number(m_value.num) + "ms";
+ break;
+ case CSS_S:
+ text = String::number(m_value.num) + "s";
+ break;
+ case CSS_HZ:
+ text = String::number(m_value.num) + "hz";
+ break;
+ case CSS_KHZ:
+ text = String::number(m_value.num) + "khz";
+ break;
+ case CSS_DIMENSION:
+ // ###
+ break;
+ case CSS_STRING:
+ text = quoteStringIfNeeded(m_value.string);
+ break;
+ case CSS_URI:
+ text = "url(" + String(m_value.string) + ")";
+ break;
+ case CSS_IDENT:
+ text = getValueName(m_value.ident);
+ break;
+ case CSS_ATTR:
+ // ###
+ break;
+ case CSS_COUNTER:
+ // ###
+ break;
+ case CSS_RECT: {
+ RectImpl* rectVal = getRectValue();
+ text = "rect(";
+ text += rectVal->top()->cssText() + " ";
+ text += rectVal->right()->cssText() + " ";
+ text += rectVal->bottom()->cssText() + " ";
+ text += rectVal->left()->cssText() + ")";
+ break;
+ }
+ case CSS_RGBCOLOR: {
+ Color color(m_value.rgbcolor);
+ if (color.alpha() < 0xFF)
+ text = "rgba(";
+ else
+ text = "rgb(";
+ text += String::number(color.red()) + ", ";
+ text += String::number(color.green()) + ", ";
+ text += String::number(color.blue());
+ if (color.alpha() < 0xFF)
+ text += ", " + String::number((float)color.alpha() / 0xFF);
+ text += ")";
+ break;
+ }
+ case CSS_PAIR:
+ text = m_value.pair->first()->cssText();
+ text += " ";
+ text += m_value.pair->second()->cssText();
+ break;
+#if __APPLE__
+ case CSS_DASHBOARD_REGION:
+ for (DashboardRegion* region = getDashboardRegionValue(); region; region = region->m_next.get()) {
+ text = "dashboard-region(";
+ text += region->m_label;
+ if (region->m_isCircle)
+ text += " circle ";
+ else if (region->m_isRectangle)
+ text += " rectangle ";
+ else
+ break;
+ text += region->top()->cssText() + " ";
+ text += region->right()->cssText() + " ";
+ text += region->bottom()->cssText() + " ";
+ text += region->left()->cssText();
+ text += ")";
+ }
+ break;
+#endif
+ }
+ return text;
+}
+
+}
diff --git a/WebCore/css/CSSPrimitiveValue.h b/WebCore/css/CSSPrimitiveValue.h
new file mode 100644
index 0000000..48fb458
--- /dev/null
+++ b/WebCore/css/CSSPrimitiveValue.h
@@ -0,0 +1,169 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSPrimitiveValue_H
+#define CSSPrimitiveValue_H
+
+#include "CSSValue.h"
+
+namespace WebCore {
+
+class Counter;
+class DashboardRegion;
+class Pair;
+class RectImpl;
+class RenderStyle;
+
+typedef int ExceptionCode;
+
+class CSSPrimitiveValue : public CSSValue
+{
+public:
+ enum UnitTypes {
+ CSS_UNKNOWN = 0,
+ CSS_NUMBER = 1,
+ CSS_PERCENTAGE = 2,
+ CSS_EMS = 3,
+ CSS_EXS = 4,
+ CSS_PX = 5,
+ CSS_CM = 6,
+ CSS_MM = 7,
+ CSS_IN = 8,
+ CSS_PT = 9,
+ CSS_PC = 10,
+ CSS_DEG = 11,
+ CSS_RAD = 12,
+ CSS_GRAD = 13,
+ CSS_MS = 14,
+ CSS_S = 15,
+ CSS_HZ = 16,
+ CSS_KHZ = 17,
+ CSS_DIMENSION = 18,
+ CSS_STRING = 19,
+ CSS_URI = 20,
+ CSS_IDENT = 21,
+ CSS_ATTR = 22,
+ CSS_COUNTER = 23,
+ CSS_RECT = 24,
+ CSS_RGBCOLOR = 25,
+ CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
+ CSS_DASHBOARD_REGION = 101 // FIXME: What on earth is this doing as a primitive value? It should not be!
+ };
+
+ // FIXME: int vs. unsigned overloading is too tricky for color vs. ident
+ CSSPrimitiveValue();
+ CSSPrimitiveValue(int ident);
+ CSSPrimitiveValue(double, UnitTypes);
+ CSSPrimitiveValue(const String&, UnitTypes);
+ CSSPrimitiveValue(PassRefPtr<Counter>);
+ CSSPrimitiveValue(PassRefPtr<RectImpl>);
+ CSSPrimitiveValue(unsigned color); // RGB value
+ CSSPrimitiveValue(PassRefPtr<Pair>);
+
+#if __APPLE__
+ CSSPrimitiveValue(PassRefPtr<DashboardRegion>); // FIXME: Why is dashboard region a primitive value? This makes no sense.
+#endif
+
+ virtual ~CSSPrimitiveValue();
+
+ void cleanup();
+
+ unsigned short primitiveType() const { return m_type; }
+
+ /*
+ * computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
+ * the fontinfo in case val is defined in em or ex.
+ *
+ * The metrics have to be a bit different for screen and printer output.
+ * For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
+ *
+ * this is screen/printer dependent, so we probably need a config option for this,
+ * and some tool to calibrate.
+ */
+ int computeLengthInt(RenderStyle*);
+ int computeLengthInt(RenderStyle*, double multiplier);
+ int computeLengthIntForLength(RenderStyle*);
+ int computeLengthIntForLength(RenderStyle*, double multiplier);
+ short computeLengthShort(RenderStyle*);
+ short computeLengthShort(RenderStyle*, double multiplier);
+ double computeLengthFloat(RenderStyle*, bool applyZoomFactor = true);
+
+ // use with care!!!
+ void setPrimitiveType(unsigned short type) { m_type = type; }
+ void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&);
+ double getFloatValue(unsigned short unitType);
+ double getFloatValue() { return m_value.num; }
+
+ void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&);
+ String getStringValue() const;
+
+ Counter* getCounterValue () const {
+ return m_type != CSS_COUNTER ? 0 : m_value.counter;
+ }
+
+ RectImpl* getRectValue () const {
+ return m_type != CSS_RECT ? 0 : m_value.rect;
+ }
+
+ unsigned getRGBColorValue() const {
+ return m_type != CSS_RGBCOLOR ? 0 : m_value.rgbcolor;
+ }
+
+ Pair* getPairValue() const {
+ return m_type != CSS_PAIR ? 0 : m_value.pair;
+ }
+
+#if __APPLE__
+ DashboardRegion *getDashboardRegionValue () const {
+ return m_type != CSS_DASHBOARD_REGION ? 0 : m_value.region;
+ }
+#endif
+
+ virtual bool isPrimitiveValue() const { return true; }
+ virtual unsigned short cssValueType() const;
+
+ int getIdent();
+
+ virtual bool parseString(const String&, bool = false);
+ virtual String cssText() const;
+
+ virtual bool isQuirkValue() { return false; }
+
+protected:
+ int m_type;
+ union {
+ int ident;
+ double num;
+ StringImpl* string;
+ Counter* counter;
+ RectImpl* rect;
+ unsigned rgbcolor;
+ Pair* pair;
+#if __APPLE__
+ DashboardRegion* region;
+#endif
+ } m_value;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSProperty.cpp b/WebCore/css/CSSProperty.cpp
new file mode 100644
index 0000000..93625d0
--- /dev/null
+++ b/WebCore/css/CSSProperty.cpp
@@ -0,0 +1,40 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSProperty.h"
+
+// Not in any header, so just declare it here for now.
+WebCore::String getPropertyName(unsigned short id);
+
+namespace WebCore {
+
+String CSSProperty::cssText() const
+{
+ return getPropertyName(id()) + ": " + m_value->cssText() + (isImportant() ? " !important" : "") + "; ";
+}
+
+bool operator==(const CSSProperty &a, const CSSProperty &b)
+{
+ return a.m_id == b.m_id && a.m_important == b.m_important && a.m_value == b.m_value;
+}
+
+}
diff --git a/WebCore/css/CSSProperty.h b/WebCore/css/CSSProperty.h
new file mode 100644
index 0000000..49f2076
--- /dev/null
+++ b/WebCore/css/CSSProperty.h
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSProperty_H
+#define CSSProperty_H
+
+#include "CSSValue.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class CSSProperty {
+public:
+ CSSProperty(int propID, PassRefPtr<CSSValue> value, bool important = false, int shorthandID = 0, bool implicit = false)
+ : m_id(propID)
+ , m_shorthandID(shorthandID)
+ , m_important(important)
+ , m_implicit(implicit)
+ , m_value(value)
+ {
+ }
+
+ CSSProperty &operator=(const CSSProperty& o)
+ {
+ m_id = o.m_id;
+ m_shorthandID = o.m_shorthandID;
+ m_important = o.m_important;
+ m_value = o.m_value;
+ return *this;
+ }
+
+ int id() const { return m_id; }
+ int shorthandID() const { return m_shorthandID; }
+
+ bool isImportant() const { return m_important; }
+ bool isImplicit() const { return m_implicit; }
+
+ CSSValue* value() const { return m_value.get(); }
+
+ String cssText() const;
+
+ // make sure the following fits in 4 bytes.
+ int m_id;
+ int m_shorthandID; // If this property was set as part of a shorthand, gives the shorthand.
+ bool m_important : 1;
+ bool m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
+
+ friend bool operator==(const CSSProperty &, const CSSProperty &);
+
+ RefPtr<CSSValue> m_value;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSQuirkPrimitiveValue.h b/WebCore/css/CSSQuirkPrimitiveValue.h
new file mode 100644
index 0000000..a3a5c57
--- /dev/null
+++ b/WebCore/css/CSSQuirkPrimitiveValue.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSQuirkPrimitiveValue_H
+#define CSSQuirkPrimitiveValue_H
+
+#include "CSSPrimitiveValue.h"
+
+namespace WebCore {
+
+// This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
+// The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em
+// in a stylesheet. When the quirky value is used, if you're in quirks mode, the margin will
+// collapse away inside a table cell.
+class CSSQuirkPrimitiveValue : public CSSPrimitiveValue
+{
+public:
+ CSSQuirkPrimitiveValue(double num, UnitTypes type)
+ : CSSPrimitiveValue(num, type) {}
+
+ virtual bool isQuirkValue() { return true; }
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSRule.cpp b/WebCore/css/CSSRule.cpp
new file mode 100644
index 0000000..376f829
--- /dev/null
+++ b/WebCore/css/CSSRule.cpp
@@ -0,0 +1,51 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 "CSSRule.h"
+
+#include "CSSStyleSheet.h"
+
+namespace WebCore {
+
+CSSStyleSheet* CSSRule::parentStyleSheet() const
+{
+ return (parent() && parent()->isCSSStyleSheet()) ? static_cast<CSSStyleSheet*>(parent()) : 0;
+}
+
+CSSRule* CSSRule::parentRule() const
+{
+ return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0;
+}
+
+String CSSRule::cssText() const
+{
+ // ###
+ return String();
+}
+
+void CSSRule::setCssText(String /*str*/)
+{
+ // ###
+}
+
+}
diff --git a/WebCore/css/CSSRule.h b/WebCore/css/CSSRule.h
new file mode 100644
index 0000000..19d18b8
--- /dev/null
+++ b/WebCore/css/CSSRule.h
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSRule_H
+#define CSSRule_H
+
+#include "css_base.h" // for StyleBase
+
+namespace WebCore {
+
+class CSSStyleSheet;
+
+class CSSRule : public StyleBase
+{
+public:
+ enum CSSRuleType {
+ UNKNOWN_RULE,
+ STYLE_RULE,
+ CHARSET_RULE,
+ IMPORT_RULE,
+ MEDIA_RULE,
+ FONT_FACE_RULE,
+ PAGE_RULE
+ };
+
+ CSSRule(StyleBase* parent) : StyleBase(parent), m_type(UNKNOWN_RULE) { }
+
+ virtual bool isRule() { return true; }
+ unsigned short type() const { return m_type; }
+
+ CSSStyleSheet* parentStyleSheet() const;
+ CSSRule* parentRule() const;
+
+ virtual String cssText() const;
+ void setCssText(String str);
+
+protected:
+ CSSRuleType m_type;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSRuleList.cpp b/WebCore/css/CSSRuleList.cpp
new file mode 100644
index 0000000..bb2ce0d
--- /dev/null
+++ b/WebCore/css/CSSRuleList.cpp
@@ -0,0 +1,79 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 "CSSRuleList.h"
+
+#include "CSSRule.h"
+#include "css_base.h" // for StyleList
+
+namespace WebCore {
+
+CSSRuleList::CSSRuleList()
+{
+}
+
+CSSRuleList::CSSRuleList(StyleList* lst)
+{
+ if (lst) {
+ unsigned len = lst->length();
+ for (unsigned i = 0; i < len; ++i) {
+ StyleBase* style = lst->item(i);
+ if (style->isRule())
+ append(static_cast<CSSRule*>(style));
+ }
+ }
+}
+
+CSSRuleList::~CSSRuleList()
+{
+ CSSRule* rule;
+ while (!m_lstCSSRules.isEmpty() && (rule = m_lstCSSRules.take(0)))
+ rule->deref();
+}
+
+void CSSRuleList::deleteRule(unsigned index)
+{
+ CSSRule* rule = m_lstCSSRules.take(index);
+ if (rule)
+ rule->deref();
+ else
+ ; // ### Throw INDEX_SIZE_ERR exception here (TODO)
+}
+
+void CSSRuleList::append(CSSRule* rule)
+{
+ insertRule(rule, m_lstCSSRules.count()) ;
+}
+
+unsigned CSSRuleList::insertRule(CSSRule* rule, unsigned index)
+{
+ if (rule && m_lstCSSRules.insert(index, rule)) {
+ rule->ref();
+ return index;
+ }
+
+ // ### Should throw INDEX_SIZE_ERR exception instead! (TODO)
+ return 0;
+}
+
+}
diff --git a/WebCore/css/CSSRuleList.h b/WebCore/css/CSSRuleList.h
new file mode 100644
index 0000000..e982b62
--- /dev/null
+++ b/WebCore/css/CSSRuleList.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSRuleList_H
+#define CSSRuleList_H
+
+#include "Shared.h"
+#include "DeprecatedPtrList.h"
+
+namespace WebCore {
+
+class CSSRule;
+class StyleList;
+
+class CSSRuleList : public Shared<CSSRuleList>
+{
+public:
+ CSSRuleList();
+ CSSRuleList(StyleList*);
+ ~CSSRuleList();
+
+ unsigned length() const { return m_lstCSSRules.count(); }
+ CSSRule* item (unsigned index) { return m_lstCSSRules.at(index); }
+
+ /* not part of the DOM */
+ unsigned insertRule (CSSRule* rule, unsigned index);
+ void deleteRule (unsigned index);
+ void append(CSSRule* rule);
+
+protected:
+ DeprecatedPtrList<CSSRule> m_lstCSSRules;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSStyleDeclaration.cpp b/WebCore/css/CSSStyleDeclaration.cpp
new file mode 100644
index 0000000..9c3043b
--- /dev/null
+++ b/WebCore/css/CSSStyleDeclaration.cpp
@@ -0,0 +1,172 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSStyleDeclaration.h"
+
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSProperty.h"
+#include "CSSPropertyNames.h"
+#include "CSSRule.h"
+#include "DeprecatedValueList.h"
+#include "ksvgcssproperties.h"
+
+// Not in any header, so just declare it here for now.
+WebCore::String getPropertyName(unsigned short id);
+
+namespace WebCore {
+
+// Defined in CSSGrammar.y, but not in any header, so just declare it here for now.
+int getPropertyID(const char* str, int len);
+
+static int propertyID(const String& s)
+{
+ char buffer[maxCSSPropertyNameLength];
+
+ unsigned len = s.length();
+ if (len > maxCSSPropertyNameLength)
+ return 0;
+
+ for (unsigned i = 0; i != len; ++i) {
+ UChar c = s[i];
+ if (c == 0 || c >= 0x7F)
+ return 0; // illegal character
+ buffer[i] = c;
+ }
+
+ int id = getPropertyID(buffer, len);
+#if SVG_SUPPORT
+ if (id == 0)
+ id = SVG::getSVGCSSPropertyID(buffer, len);
+#endif
+ return id;
+}
+
+CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parent)
+ : StyleBase(parent)
+{
+}
+
+bool CSSStyleDeclaration::isStyleDeclaration()
+{
+ return true;
+}
+
+PassRefPtr<CSSValue> CSSStyleDeclaration::getPropertyCSSValue(const String& propertyName)
+{
+ int propID = propertyID(propertyName);
+ if (!propID)
+ return 0;
+ return getPropertyCSSValue(propID);
+}
+
+String CSSStyleDeclaration::getPropertyValue(const String &propertyName)
+{
+ int propID = propertyID(propertyName);
+ if (!propID)
+ return String();
+ return getPropertyValue(propID);
+}
+
+String CSSStyleDeclaration::getPropertyPriority(const String &propertyName)
+{
+ int propID = propertyID(propertyName);
+ if (!propID)
+ return String();
+ return getPropertyPriority(propID) ? "important" : "";
+}
+
+String CSSStyleDeclaration::getPropertyShorthand(const String &propertyName)
+{
+ int propID = propertyID(propertyName);
+ if (!propID)
+ return String();
+ int shorthandID = getPropertyShorthand(propID);
+ if (!shorthandID)
+ return String();
+ return getPropertyName(shorthandID);
+}
+
+bool CSSStyleDeclaration::isPropertyImplicit(const String &propertyName)
+{
+ int propID = propertyID(propertyName);
+ if (!propID)
+ return false;
+ return isPropertyImplicit(propID);
+}
+
+void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
+{
+ int propID = propertyID(propertyName);
+ if (!propID) // set exception?
+ return;
+ bool important = priority.find("important", 0, false) != -1;
+ setProperty(propID, value, important, ec);
+}
+
+String CSSStyleDeclaration::removeProperty(const String& propertyName, ExceptionCode& ec)
+{
+ int propID = propertyID(propertyName);
+ if (!propID)
+ return String();
+ return removeProperty(propID, ec);
+}
+
+bool CSSStyleDeclaration::isPropertyName(const String &propertyName)
+{
+ return propertyID(propertyName);
+}
+
+CSSRule *CSSStyleDeclaration::parentRule() const
+{
+ return (parent() && parent()->isRule()) ? static_cast<CSSRule *>(parent()) : 0;
+}
+
+void CSSStyleDeclaration::diff(CSSMutableStyleDeclaration *style) const
+{
+ if (!style)
+ return;
+
+ DeprecatedValueList<int> properties;
+ DeprecatedValueListConstIterator<CSSProperty> end;
+ for (DeprecatedValueListConstIterator<CSSProperty> it(style->valuesIterator()); it != end; ++it) {
+ const CSSProperty& property = *it;
+ RefPtr<CSSValue> value = getPropertyCSSValue(property.id());
+ if (value && (value->cssText() == property.value()->cssText()))
+ properties.append(property.id());
+ }
+
+ for (DeprecatedValueListIterator<int> it(properties.begin()); it != properties.end(); ++it)
+ style->removeProperty(*it);
+}
+
+PassRefPtr<CSSMutableStyleDeclaration> CSSStyleDeclaration::copyPropertiesInSet(const int *set, unsigned length) const
+{
+ DeprecatedValueList<CSSProperty> list;
+ for (unsigned i = 0; i < length; i++) {
+ RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
+ if (value)
+ list.append(CSSProperty(set[i], value.release(), false));
+ }
+ return new CSSMutableStyleDeclaration(0, list);
+}
+
+}
diff --git a/WebCore/css/CSSStyleDeclaration.h b/WebCore/css/CSSStyleDeclaration.h
new file mode 100644
index 0000000..806c18e
--- /dev/null
+++ b/WebCore/css/CSSStyleDeclaration.h
@@ -0,0 +1,82 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSStyleDeclaration_H
+#define CSSStyleDeclaration_H
+
+#include "css_base.h" // for StyleBase
+
+namespace WebCore {
+
+class CSSMutableStyleDeclaration;
+
+typedef int ExceptionCode;
+
+class CSSStyleDeclaration : public StyleBase {
+public:
+ virtual bool isStyleDeclaration();
+
+ static bool isPropertyName(const String& propertyName);
+
+ CSSRule* parentRule() const;
+
+ virtual String cssText() const = 0;
+ virtual void setCssText(const String&, ExceptionCode&) = 0;
+
+ virtual unsigned length() const = 0;
+ virtual String item(unsigned index) const = 0;
+
+ PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
+ String getPropertyValue(const String& propertyName);
+ String getPropertyPriority(const String& propertyName);
+ String getPropertyShorthand(const String& propertyName);
+ bool isPropertyImplicit(const String& propertyName);
+
+ virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const = 0;
+ virtual String getPropertyValue(int propertyID) const = 0;
+ virtual bool getPropertyPriority(int propertyID) const = 0;
+ virtual int getPropertyShorthand(int propertyID) const = 0;
+ virtual bool isPropertyImplicit(int propertyID) const = 0;
+
+ void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
+ String removeProperty(const String& propertyName, ExceptionCode&);
+ virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&) = 0;
+ virtual String removeProperty(int propertyID, ExceptionCode&) = 0;
+
+ virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const = 0;
+ virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable() = 0;
+
+ void diff(CSSMutableStyleDeclaration*) const;
+
+ PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
+
+protected:
+ CSSStyleDeclaration(CSSRule* parentRule = 0);
+
+private:
+ CSSStyleDeclaration(const CSSStyleDeclaration &);
+ CSSStyleDeclaration& operator=(const CSSStyleDeclaration &);
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSStyleRule.cpp b/WebCore/css/CSSStyleRule.cpp
new file mode 100644
index 0000000..50d3633
--- /dev/null
+++ b/WebCore/css/CSSStyleRule.cpp
@@ -0,0 +1,85 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 "CSSStyleRule.h"
+
+#include "CSSMutableStyleDeclaration.h"
+
+namespace WebCore {
+
+CSSStyleRule::CSSStyleRule(StyleBase* parent)
+ : CSSRule(parent)
+ , m_selector(0)
+{
+ m_type = STYLE_RULE;
+}
+
+CSSStyleRule::~CSSStyleRule()
+{
+ if (m_style)
+ m_style->setParent(0);
+ delete m_selector;
+}
+
+String CSSStyleRule::selectorText() const
+{
+ if (m_selector) {
+ String str;
+ for (CSSSelector* s = m_selector; s; s = s->next()) {
+ if (s != m_selector)
+ str += ", ";
+ str += s->selectorText();
+ }
+ return str;
+ }
+ return String();
+}
+
+void CSSStyleRule::setSelectorText(String /*str*/)
+{
+ // ###
+}
+
+String CSSStyleRule::cssText() const
+{
+ String result = selectorText();
+
+ result += " { ";
+ result += m_style->cssText();
+ result += "}";
+
+ return result;
+}
+
+bool CSSStyleRule::parseString( const String &/*string*/, bool )
+{
+ // ###
+ return false;
+}
+
+void CSSStyleRule::setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style)
+{
+ m_style = style;
+}
+
+}
diff --git a/WebCore/css/CSSStyleRule.h b/WebCore/css/CSSStyleRule.h
new file mode 100644
index 0000000..e729eeb
--- /dev/null
+++ b/WebCore/css/CSSStyleRule.h
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSStyleRule_H
+#define CSSStyleRule_H
+
+#include "CSSRule.h"
+
+namespace WebCore {
+
+class CSSMutableStyleDeclaration;
+
+class CSSStyleRule : public CSSRule
+{
+public:
+ CSSStyleRule(StyleBase* parent);
+ virtual ~CSSStyleRule();
+
+ CSSMutableStyleDeclaration* style() const { return m_style.get(); }
+
+ virtual bool isStyleRule() { return true; }
+ virtual String cssText() const;
+
+ String selectorText() const;
+ void setSelectorText(String);
+
+ virtual bool parseString(const String&, bool = false);
+
+ void setSelector(CSSSelector* selector) { m_selector = selector; }
+ void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);
+
+ CSSSelector* selector() { return m_selector; }
+ CSSMutableStyleDeclaration* declaration() { return m_style.get(); }
+
+protected:
+ RefPtr<CSSMutableStyleDeclaration> m_style;
+ CSSSelector* m_selector;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSStyleSheet.cpp b/WebCore/css/CSSStyleSheet.cpp
index 0a3318d..4c805f6 100644
--- a/WebCore/css/CSSStyleSheet.cpp
+++ b/WebCore/css/CSSStyleSheet.cpp
@@ -22,8 +22,9 @@
#include "config.h"
#include "CSSStyleSheet.h"
-#include "css_ruleimpl.h"
-#include "CSSParser.h"
+#include "CSSImportRule.h"
+#include "cssparser.h"
+#include "CSSRuleList.h"
#include "Document.h"
#include "ExceptionCode.h"
#include "Node.h"
@@ -56,7 +57,7 @@
CSSRule *CSSStyleSheet::ownerRule() const
{
- return (parent() && parent()->isRule()) ? static_cast<CSSRule *>(parent()) : 0;
+ return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0;
}
unsigned CSSStyleSheet::insertRule(const String& rule, unsigned index, ExceptionCode& ec)
diff --git a/WebCore/css/CSSUnknownRule.h b/WebCore/css/CSSUnknownRule.h
new file mode 100644
index 0000000..a735442
--- /dev/null
+++ b/WebCore/css/CSSUnknownRule.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2002, 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 CSSUnknownRule_H
+#define CSSUnknownRule_H
+
+#include "CSSRule.h"
+
+namespace WebCore {
+
+class CSSUnknownRule : public CSSRule {
+public:
+ CSSUnknownRule(StyleBase* parent) : CSSRule(parent) { }
+
+ virtual bool isUnknownRule() { return true; }
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSValue.h b/WebCore/css/CSSValue.h
new file mode 100644
index 0000000..4fdf5f4
--- /dev/null
+++ b/WebCore/css/CSSValue.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSValue_H
+#define CSSValue_H
+
+#include "css_base.h" // for StyleBase
+
+namespace WebCore {
+
+class CSSValue : public StyleBase
+{
+public:
+ enum UnitTypes {
+ CSS_INHERIT = 0,
+ CSS_PRIMITIVE_VALUE = 1,
+ CSS_VALUE_LIST = 2,
+ CSS_CUSTOM = 3,
+ CSS_INITIAL = 4
+ };
+
+ CSSValue() : StyleBase(0) { }
+
+ virtual unsigned short cssValueType() const { return CSS_CUSTOM; }
+ virtual String cssText() const = 0;
+ void setCssText(const String&) { } // FIXME: Not implemented.
+
+ virtual bool isValue() { return true; }
+ virtual bool isFontValue() { return false; }
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/CSSValueList.cpp b/WebCore/css/CSSValueList.cpp
new file mode 100644
index 0000000..caeeadb
--- /dev/null
+++ b/WebCore/css/CSSValueList.cpp
@@ -0,0 +1,56 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "CSSValueList.h"
+
+namespace WebCore {
+
+CSSValueList::~CSSValueList()
+{
+ for (CSSValue *val = m_values.first(); val; val = m_values.next())
+ val->deref();
+}
+
+unsigned short CSSValueList::cssValueType() const
+{
+ return CSS_VALUE_LIST;
+}
+
+void CSSValueList::append(PassRefPtr<CSSValue> val)
+{
+ m_values.append(val.release());
+}
+
+String CSSValueList::cssText() const
+{
+ String result = "";
+
+ for (DeprecatedPtrListIterator<CSSValue> iterator(m_values); iterator.current(); ++iterator) {
+ if (!result.isEmpty())
+ result += ", ";
+ result += iterator.current()->cssText();
+ }
+
+ return result;
+}
+
+}
diff --git a/WebCore/css/CSSValueList.h b/WebCore/css/CSSValueList.h
new file mode 100644
index 0000000..062fe04
--- /dev/null
+++ b/WebCore/css/CSSValueList.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef CSSValueList_H
+#define CSSValueList_H
+
+#include "CSSValue.h"
+#include "DeprecatedPtrList.h"
+
+namespace WebCore {
+
+class CSSValueList : public CSSValue
+{
+public:
+ virtual ~CSSValueList();
+
+ unsigned length() const { return m_values.count(); }
+ CSSValue* item (unsigned index) { return m_values.at(index); }
+
+ virtual bool isValueList() { return true; }
+
+ virtual unsigned short cssValueType() const;
+
+ void append(PassRefPtr<CSSValue>);
+ virtual String cssText() const;
+
+protected:
+ DeprecatedPtrList<CSSValue> m_values;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/Counter.h b/WebCore/css/Counter.h
new file mode 100644
index 0000000..2f65424
--- /dev/null
+++ b/WebCore/css/Counter.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef Counter_H
+#define Counter_H
+
+#include "Shared.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class Counter : public Shared<Counter> {
+public:
+ String identifier() const { return m_identifier; }
+ String listStyle() const { return m_listStyle; }
+ String separator() const { return m_separator; }
+
+private:
+ String m_identifier;
+ String m_listStyle;
+ String m_separator;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/DashboardRegion.h b/WebCore/css/DashboardRegion.h
new file mode 100644
index 0000000..955fbe0
--- /dev/null
+++ b/WebCore/css/DashboardRegion.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef DashboardRegion_H
+#define DashboardRegion_H
+
+#include "RectImpl.h"
+
+namespace WebCore {
+
+class DashboardRegion : public RectImpl {
+public:
+ DashboardRegion() : m_isCircle(0), m_isRectangle(0) { }
+
+ RefPtr<DashboardRegion> m_next;
+ String m_label;
+ String m_geometryType;
+ bool m_isCircle : 1;
+ bool m_isRectangle : 1;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/FontFamilyValue.cpp b/WebCore/css/FontFamilyValue.cpp
new file mode 100644
index 0000000..910a1ab
--- /dev/null
+++ b/WebCore/css/FontFamilyValue.cpp
@@ -0,0 +1,63 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "FontFamilyValue.h"
+
+#include "RegularExpression.h"
+
+namespace WebCore {
+
+// Quotes the string if it needs quoting.
+// We use single quotes for now beause markup.cpp uses double quotes.
+static String quoteStringIfNeeded(const String &string)
+{
+ // For now, just do this for strings that start with "#" to fix Korean font names that start with "#".
+ // Post-Tiger, we should isLegalIdentifier instead after working out all the ancillary issues.
+ if (string[0] != '#')
+ return string;
+
+ // FIXME: Also need to transform control characters into \ sequences.
+ String s = string;
+ s.replace('\\', "\\\\");
+ s.replace('\'', "\\'");
+ return "'" + s + "'";
+}
+
+FontFamilyValue::FontFamilyValue(const DeprecatedString& string)
+ : CSSPrimitiveValue(String(), CSS_STRING)
+{
+ static const RegularExpression parenReg(" \\(.*\\)$");
+ static const RegularExpression braceReg(" \\[.*\\]$");
+
+ parsedFontName = string;
+ // a language tag is often added in braces at the end. Remove it.
+ parsedFontName.replace(parenReg, "");
+ // remove [Xft] qualifiers
+ parsedFontName.replace(braceReg, "");
+}
+
+String FontFamilyValue::cssText() const
+{
+ return quoteStringIfNeeded(parsedFontName);
+}
+
+}
diff --git a/WebCore/css/FontFamilyValue.h b/WebCore/css/FontFamilyValue.h
new file mode 100644
index 0000000..75e6582
--- /dev/null
+++ b/WebCore/css/FontFamilyValue.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef FontFamilyValue_H
+#define FontFamilyValue_H
+
+#include "CSSPrimitiveValue.h"
+#include "DeprecatedString.h"
+
+namespace WebCore {
+
+class FontFamilyValue : public CSSPrimitiveValue
+{
+public:
+ FontFamilyValue(const DeprecatedString& string);
+ const DeprecatedString& fontName() const { return parsedFontName; }
+ int genericFamilyType() const { return m_genericFamilyType; }
+
+ virtual String cssText() const;
+
+ DeprecatedString parsedFontName;
+private:
+ int m_genericFamilyType;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/FontValue.cpp b/WebCore/css/FontValue.cpp
new file mode 100644
index 0000000..f39643a
--- /dev/null
+++ b/WebCore/css/FontValue.cpp
@@ -0,0 +1,68 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "FontValue.h"
+
+#include "CSSValueList.h"
+#include "CSSPrimitiveValue.h"
+
+namespace WebCore {
+
+String FontValue::cssText() const
+{
+ // font variant weight size / line-height family
+
+ String result("");
+
+ if (style)
+ result += style->cssText();
+ if (variant) {
+ if (!result.isEmpty())
+ result += " ";
+ result += variant->cssText();
+ }
+ if (weight) {
+ if (!result.isEmpty())
+ result += " ";
+ result += weight->cssText();
+ }
+ if (size) {
+ if (!result.isEmpty())
+ result += " ";
+ result += size->cssText();
+ }
+ if (lineHeight) {
+ if (!size)
+ result += " ";
+ result += "/";
+ result += lineHeight->cssText();
+ }
+ if (family) {
+ if (!result.isEmpty())
+ result += " ";
+ result += family->cssText();
+ }
+
+ return result;
+}
+
+}
diff --git a/WebCore/css/FontValue.h b/WebCore/css/FontValue.h
new file mode 100644
index 0000000..9bab2cd
--- /dev/null
+++ b/WebCore/css/FontValue.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef FontValue_H
+#define FontValue_H
+
+#include "CSSValue.h"
+
+namespace WebCore {
+
+class CSSValueList;
+
+class FontValue : public CSSValue
+{
+public:
+ virtual String cssText() const;
+
+ virtual bool isFontValue() { return true; }
+
+ RefPtr<CSSPrimitiveValue> style;
+ RefPtr<CSSPrimitiveValue> variant;
+ RefPtr<CSSPrimitiveValue> weight;
+ RefPtr<CSSPrimitiveValue> size;
+ RefPtr<CSSPrimitiveValue> lineHeight;
+ RefPtr<CSSValueList> family;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/MediaList.cpp b/WebCore/css/MediaList.cpp
index 7bc580a..675e595 100644
--- a/WebCore/css/MediaList.cpp
+++ b/WebCore/css/MediaList.cpp
@@ -22,8 +22,8 @@
#include "config.h"
#include "MediaList.h"
+#include "CSSRule.h"
#include "CSSStyleSheet.h"
-#include "css_ruleimpl.h"
#include "DeprecatedStringList.h"
namespace WebCore {
diff --git a/WebCore/css/Pair.h b/WebCore/css/Pair.h
new file mode 100644
index 0000000..edf9762
--- /dev/null
+++ b/WebCore/css/Pair.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef Pair_H
+#define Pair_H
+
+#include "Shared.h"
+#include "CSSPrimitiveValue.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+// A primitive value representing a pair. This is useful for properties like border-radius, background-size/position,
+// and border-spacing (all of which are space-separated sets of two values). At the moment we are only using it for
+// border-radius and background-size, but (FIXME) border-spacing and background-position could be converted over to use
+// it (eliminating some extra -webkit- internal properties).
+class Pair : public Shared<Pair> {
+public:
+ Pair() : m_first(0), m_second(0) { }
+ Pair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> second)
+ : m_first(first), m_second(second) { }
+ virtual ~Pair() { }
+
+ CSSPrimitiveValue* first() const { return m_first.get(); }
+ CSSPrimitiveValue* second() const { return m_second.get(); }
+
+ void setFirst(PassRefPtr<CSSPrimitiveValue> first) { m_first = first; }
+ void setSecond(PassRefPtr<CSSPrimitiveValue> second) { m_second = second; }
+
+protected:
+ RefPtr<CSSPrimitiveValue> m_first;
+ RefPtr<CSSPrimitiveValue> m_second;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/RectImpl.h b/WebCore/css/RectImpl.h
new file mode 100644
index 0000000..e8d3341
--- /dev/null
+++ b/WebCore/css/RectImpl.h
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef RectImpl_H
+#define RectImpl_H
+
+#include "Shared.h"
+#include "CSSPrimitiveValue.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class RectImpl : public Shared<RectImpl> {
+public:
+ virtual ~RectImpl() { }
+
+ CSSPrimitiveValue* top() const { return m_top.get(); }
+ CSSPrimitiveValue* right() const { return m_right.get(); }
+ CSSPrimitiveValue* bottom() const { return m_bottom.get(); }
+ CSSPrimitiveValue* left() const { return m_left.get(); }
+
+ void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
+ void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; }
+ void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
+ void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
+
+protected:
+ RefPtr<CSSPrimitiveValue> m_top;
+ RefPtr<CSSPrimitiveValue> m_right;
+ RefPtr<CSSPrimitiveValue> m_bottom;
+ RefPtr<CSSPrimitiveValue> m_left;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/ShadowValue.cpp b/WebCore/css/ShadowValue.cpp
new file mode 100644
index 0000000..874be67
--- /dev/null
+++ b/WebCore/css/ShadowValue.cpp
@@ -0,0 +1,66 @@
+/**
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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 "ShadowValue.h"
+
+#include "CSSPrimitiveValue.h"
+
+namespace WebCore {
+
+// Used for text-shadow and box-shadow
+ShadowValue::ShadowValue(PassRefPtr<CSSPrimitiveValue> _x,
+ PassRefPtr<CSSPrimitiveValue> _y,
+ PassRefPtr<CSSPrimitiveValue> _blur,
+ PassRefPtr<CSSPrimitiveValue> _color)
+ : x(_x)
+ , y(_y)
+ , blur(_blur)
+ , color(_color)
+{
+}
+
+String ShadowValue::cssText() const
+{
+ String text("");
+
+ if (color)
+ text += color->cssText();
+ if (x) {
+ if (!text.isEmpty())
+ text += " ";
+ text += x->cssText();
+ }
+ if (y) {
+ if (!text.isEmpty())
+ text += " ";
+ text += y->cssText();
+ }
+ if (blur) {
+ if (!text.isEmpty())
+ text += " ";
+ text += blur->cssText();
+ }
+
+ return text;
+}
+
+}
diff --git a/WebCore/css/ShadowValue.h b/WebCore/css/ShadowValue.h
new file mode 100644
index 0000000..610bee9
--- /dev/null
+++ b/WebCore/css/ShadowValue.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999-2003 Lars Knoll (knoll@kde.org)
+ * 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.
+ */
+
+#ifndef ShadowValue_H
+#define ShadowValue_H
+
+#include "CSSValue.h"
+
+namespace WebCore {
+
+// Used for text-shadow and box-shadow
+class ShadowValue : public CSSValue
+{
+public:
+ ShadowValue(PassRefPtr<CSSPrimitiveValue> x,
+ PassRefPtr<CSSPrimitiveValue> y,
+ PassRefPtr<CSSPrimitiveValue> blur,
+ PassRefPtr<CSSPrimitiveValue> color);
+
+ virtual String cssText() const;
+
+ RefPtr<CSSPrimitiveValue> x;
+ RefPtr<CSSPrimitiveValue> y;
+ RefPtr<CSSPrimitiveValue> blur;
+ RefPtr<CSSPrimitiveValue> color;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/css_base.cpp b/WebCore/css/css_base.cpp
index bc9d38e..74b1a23 100644
--- a/WebCore/css/css_base.cpp
+++ b/WebCore/css/css_base.cpp
@@ -27,7 +27,6 @@
#include "css_base.h"
#include "Document.h"
-#include "css_valueimpl.h"
#include "StyleSheet.h"
namespace WebCore {
diff --git a/WebCore/css/css_ruleimpl.cpp b/WebCore/css/css_ruleimpl.cpp
deleted file mode 100644
index eb5a8c0..0000000
--- a/WebCore/css/css_ruleimpl.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/**
- * This file is part of the DOM implementation for KDE.
- *
- * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2002, 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 "css_ruleimpl.h"
-
-#include "Cache.h"
-#include "CachedCSSStyleSheet.h"
-#include "CSSStyleSheet.h"
-#include "DocLoader.h"
-#include "MediaList.h"
-#include "cssparser.h"
-#include <KURL.h>
-
-namespace WebCore {
-
-CSSStyleSheet* CSSRule::parentStyleSheet() const
-{
- return (parent() && parent()->isCSSStyleSheet()) ? static_cast<CSSStyleSheet*>(parent()) : 0;
-}
-
-CSSRule* CSSRule::parentRule() const
-{
- return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0;
-}
-
-String CSSRule::cssText() const
-{
- // ###
- return String();
-}
-
-void CSSRule::setCssText(String /*str*/)
-{
- // ###
-}
-
-// ---------------------------------------------------------------------------
-
-CSSFontFaceRule::CSSFontFaceRule(StyleBase *parent)
- : CSSRule(parent)
-{
- m_type = FONT_FACE_RULE;
-}
-
-CSSFontFaceRule::~CSSFontFaceRule()
-{
-}
-
-// --------------------------------------------------------------------------
-
-CSSImportRule::CSSImportRule(StyleBase* parent, const String& href, MediaList* media)
- : CSSRule(parent)
- , m_strHref(href)
- , m_lstMedia(media)
- , m_cachedSheet(0)
- , m_loading(false)
-{
- m_type = IMPORT_RULE;
-
- if (m_lstMedia)
- m_lstMedia->setParent(this);
- else
- m_lstMedia = new MediaList(this, String());
-}
-
-CSSImportRule::~CSSImportRule()
-{
- if (m_lstMedia)
- m_lstMedia->setParent(0);
- if (m_styleSheet)
- m_styleSheet->setParent(0);
- if (m_cachedSheet)
- m_cachedSheet->deref(this);
-}
-
-void CSSImportRule::setStyleSheet(const String &url, const String &sheet)
-{
- if (m_styleSheet)
- m_styleSheet->setParent(0);
- m_styleSheet = new CSSStyleSheet(this, url);
-
- CSSStyleSheet *parent = parentStyleSheet();
- m_styleSheet->parseString(sheet, !parent || parent->useStrictParsing());
- m_loading = false;
-
- checkLoaded();
-}
-
-bool CSSImportRule::isLoading() const
-{
- return m_loading || (m_styleSheet && m_styleSheet->isLoading());
-}
-
-void CSSImportRule::insertedIntoParent()
-{
- StyleBase* root = this;
- StyleBase* parent;
- while ((parent = root->parent()))
- root = parent;
- if (!root->isCSSStyleSheet())
- return;
- DocLoader* docLoader = static_cast<CSSStyleSheet*>(root)->docLoader();
- if (!docLoader)
- return;
-
- String absHref = m_strHref;
- CSSStyleSheet* 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;
-
- // ### pass correct charset here!!
- m_cachedSheet = docLoader->requestStyleSheet(absHref, DeprecatedString::null);
- if (m_cachedSheet) {
- m_loading = true;
- m_cachedSheet->ref(this);
- }
-}
-
-String CSSImportRule::cssText() const
-{
- String result = "@import url(\"";
- result += m_strHref;
- result += "\")";
-
- if (m_lstMedia) {
- result += " ";
- result += m_lstMedia->mediaText();
- }
- result += ";";
-
- return result;
-}
-
-// --------------------------------------------------------------------------
-CSSMediaRule::CSSMediaRule( StyleBase *parent, MediaList *mediaList, CSSRuleList *ruleList )
- : CSSRule( parent )
-{
- m_type = MEDIA_RULE;
- m_lstMedia = mediaList;
- m_lstCSSRules = ruleList;
-}
-
-CSSMediaRule::CSSMediaRule(StyleBase *parent)
- : CSSRule( parent )
-{
- m_type = MEDIA_RULE;
- m_lstMedia = 0;
- m_lstCSSRules = new CSSRuleList();
-}
-
-CSSMediaRule::CSSMediaRule( StyleBase *parent, const String &media )
-: CSSRule( parent )
-{
- m_type = MEDIA_RULE;
- m_lstMedia = new MediaList( this, media );
- m_lstCSSRules = new CSSRuleList();
-}
-
-CSSMediaRule::~CSSMediaRule()
-{
- if(m_lstMedia)
- m_lstMedia->setParent(0);
-
- int length = m_lstCSSRules->length();
- for (int i = 0; i < length; i++)
- m_lstCSSRules->item(i)->setParent(0);
-}
-
-unsigned CSSMediaRule::append( CSSRule *rule )
-{
- if (!rule) {
- return 0;
- }
-
- rule->setParent(this);
- return m_lstCSSRules->insertRule( rule, m_lstCSSRules->length() );
-}
-
-unsigned CSSMediaRule::insertRule(const String& rule, unsigned index)
-{
- CSSParser p(useStrictParsing());
- RefPtr<CSSRule> newRule = p.parseRule(parentStyleSheet(), rule);
- if (!newRule)
- return 0;
- newRule->setParent(this);
- return m_lstCSSRules->insertRule(newRule.get(), index);
-}
-
-String CSSMediaRule::cssText() const
-{
- String result = "@media ";
- if (m_lstMedia) {
- result += m_lstMedia->mediaText();
- result += " ";
- }
- result += "{ \n";
-
- if (m_lstCSSRules) {
- unsigned len = m_lstCSSRules->length();
- for (unsigned i = 0; i < len; i++) {
- result += " ";
- result += m_lstCSSRules->item(i)->cssText();
- result += "\n";
- }
- }
-
- result += "}";
- return result;
-}
-
-// ---------------------------------------------------------------------------
-
-CSSRuleList::CSSRuleList(StyleList *lst)
-{
- if (lst) {
- unsigned len = lst->length();
- for (unsigned i = 0; i < len; ++i) {
- StyleBase *style = lst->item(i);
- if (style->isRule())
- append(static_cast<CSSRule*>(style));
- }
- }
-}
-
-CSSRuleList::~CSSRuleList()
-{
- CSSRule* rule;
- while ( !m_lstCSSRules.isEmpty() && ( rule = m_lstCSSRules.take( 0 ) ) )
- rule->deref();
-}
-
-// ---------------------------------------------------------------------------
-
-CSSPageRule::CSSPageRule(StyleBase *parent)
- : CSSRule(parent)
-{
- m_type = PAGE_RULE;
-}
-
-CSSPageRule::~CSSPageRule()
-{
-}
-
-String CSSPageRule::selectorText() const
-{
- // ###
- return String();
-}
-
-void CSSPageRule::setSelectorText(String /*str*/)
-{
- // ###
-}
-
-// --------------------------------------------------------------------------
-
-CSSStyleRule::CSSStyleRule(StyleBase *parent)
- : CSSRule(parent)
-{
- m_type = STYLE_RULE;
- m_selector = 0;
-}
-
-CSSStyleRule::~CSSStyleRule()
-{
- if (m_style)
- m_style->setParent(0);
- delete m_selector;
-}
-
-String CSSStyleRule::selectorText() const
-{
- if (m_selector) {
- String str;
- for (CSSSelector *s = m_selector; s; s = s->next()) {
- if (s != m_selector)
- str += ", ";
- str += s->selectorText();
- }
- return str;
- }
- return String();
-}
-
-void CSSStyleRule::setSelectorText(String /*str*/)
-{
- // ###
-}
-
-String CSSStyleRule::cssText() const
-{
- String result = selectorText();
-
- result += " { ";
- result += m_style->cssText();
- result += "}";
-
- return result;
-}
-
-bool CSSStyleRule::parseString( const String &/*string*/, bool )
-{
- // ###
- return false;
-}
-
-void CSSStyleRule::setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style)
-{
- m_style = style;
-}
-
-void CSSRuleList::deleteRule ( unsigned index )
-{
- CSSRule *rule = m_lstCSSRules.take( index );
- if( rule )
- rule->deref();
- else
- ; // ### Throw INDEX_SIZE_ERR exception here (TODO)
-}
-
-void CSSRuleList::append( CSSRule *rule )
-{
- insertRule( rule, m_lstCSSRules.count() ) ;
-}
-
-unsigned CSSRuleList::insertRule( CSSRule *rule, unsigned index )
-{
- if( rule && m_lstCSSRules.insert( index, rule ) )
- {
- rule->ref();
- return index;
- }
-
- // ### Should throw INDEX_SIZE_ERR exception instead! (TODO)
- return 0;
-}
-
-}
diff --git a/WebCore/css/css_ruleimpl.h b/WebCore/css/css_ruleimpl.h
deleted file mode 100644
index 6530dc0..0000000
--- a/WebCore/css/css_ruleimpl.h
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2002, 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 CSS_css_ruleimpl_h_
-#define CSS_css_ruleimpl_h_
-
-#include "css_valueimpl.h"
-
-namespace WebCore {
-
-class CachedCSSStyleSheet;
-class CSSMutableStyleDeclaration;
-class CSSStyleSheet;
-class CSSStyleSheet;
-class MediaList;
-
-class CSSRule : public StyleBase
-{
-public:
- enum CSSRuleType {
- UNKNOWN_RULE,
- STYLE_RULE,
- CHARSET_RULE,
- IMPORT_RULE,
- MEDIA_RULE,
- FONT_FACE_RULE,
- PAGE_RULE
- };
-
- CSSRule(StyleBase *parent)
- : StyleBase(parent), m_type(UNKNOWN_RULE) {}
-
- virtual bool isRule() { return true; }
- unsigned short type() const { return m_type; }
-
- CSSStyleSheet *parentStyleSheet() const;
- CSSRule *parentRule() const;
-
- virtual String cssText() const;
- void setCssText(WebCore::String str);
-
-protected:
- CSSRuleType m_type;
-};
-
-
-class CSSCharsetRule : public CSSRule
-{
-public:
- CSSCharsetRule(StyleBase *parent)
- : CSSRule(parent) { m_type = CHARSET_RULE; }
-
- virtual bool isCharsetRule() { return true; }
- virtual String cssText() const;
-
- String encoding() const { return m_encoding; }
- void setEncoding(String _encoding) { m_encoding = _encoding; }
-
-protected:
- String m_encoding;
-};
-
-
-class CSSFontFaceRule : public CSSRule
-{
-public:
- CSSFontFaceRule(StyleBase *parent);
- virtual ~CSSFontFaceRule();
-
- CSSMutableStyleDeclaration *style() const { return m_style.get(); }
-
- virtual bool isFontFaceRule() { return true; }
-
-protected:
- RefPtr<CSSMutableStyleDeclaration> m_style;
-};
-
-
-class CSSImportRule : public CachedObjectClient, public CSSRule
-{
-public:
- CSSImportRule(StyleBase* parent, const String& href, MediaList*);
- virtual ~CSSImportRule();
-
- String href() const { return m_strHref; }
- MediaList* media() const { return m_lstMedia.get(); }
- CSSStyleSheet* styleSheet() const { return m_styleSheet.get(); }
-
- virtual bool isImportRule() { return true; }
- virtual String cssText() const;
-
- bool isLoading() const;
-
- // from CachedObjectClient
- virtual void setStyleSheet(const String& url, const String& sheet);
-
- virtual void insertedIntoParent();
-
-protected:
- String m_strHref;
- RefPtr<MediaList> m_lstMedia;
- RefPtr<CSSStyleSheet> m_styleSheet;
- CachedCSSStyleSheet* m_cachedSheet;
- bool m_loading;
-};
-
-class MediaList;
-
-class CSSRuleList : public Shared<CSSRuleList>
-{
-public:
- CSSRuleList() { }
- CSSRuleList(StyleList *);
- ~CSSRuleList();
-
- unsigned length() const { return m_lstCSSRules.count(); }
- CSSRule *item ( unsigned index ) { return m_lstCSSRules.at( index ); }
-
- /* not part of the DOM */
- unsigned insertRule ( CSSRule *rule, unsigned index );
- void deleteRule ( unsigned index );
- void append( CSSRule *rule );
-
-protected:
- DeprecatedPtrList<CSSRule> m_lstCSSRules;
-};
-
-class CSSMediaRule : public CSSRule
-{
-public:
- CSSMediaRule( StyleBase *parent );
- CSSMediaRule( StyleBase *parent, const WebCore::String &media );
- CSSMediaRule( StyleBase *parent, MediaList *mediaList, CSSRuleList *ruleList );
- virtual ~CSSMediaRule();
-
- MediaList *media() const { return m_lstMedia.get(); }
- CSSRuleList *cssRules() { return m_lstCSSRules.get(); }
-
- unsigned insertRule ( const WebCore::String &rule, unsigned index );
- void deleteRule ( unsigned index ) { m_lstCSSRules->deleteRule( index ); }
-
- virtual bool isMediaRule() { return true; }
- virtual String cssText() const;
-
- /* Not part of the DOM */
- unsigned append( CSSRule *rule );
-protected:
- RefPtr<MediaList> m_lstMedia;
- RefPtr<CSSRuleList> m_lstCSSRules;
-};
-
-
-class CSSPageRule : public CSSRule
-{
-public:
- CSSPageRule(StyleBase *parent);
- virtual ~CSSPageRule();
-
- CSSMutableStyleDeclaration *style() const { return m_style.get(); }
-
- virtual bool isPageRule() { return true; }
-
- WebCore::String selectorText() const;
- void setSelectorText(WebCore::String str);
-
-protected:
- RefPtr<CSSMutableStyleDeclaration> m_style;
-};
-
-class CSSImportantRule;
-
-class CSSStyleRule : public CSSRule
-{
-public:
- CSSStyleRule(StyleBase* parent);
- virtual ~CSSStyleRule();
-
- CSSMutableStyleDeclaration* style() const { return m_style.get(); }
-
- virtual bool isStyleRule() { return true; }
- virtual String cssText() const;
-
- WebCore::String selectorText() const;
- void setSelectorText(WebCore::String str);
-
- virtual bool parseString( const String &string, bool = false );
-
- void setSelector(CSSSelector* selector) { m_selector = selector; }
- void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);
-
- CSSSelector* selector() { return m_selector; }
- CSSMutableStyleDeclaration* declaration() { return m_style.get(); }
-
-protected:
- RefPtr<CSSMutableStyleDeclaration> m_style;
- CSSSelector* m_selector;
-};
-
-class CSSUnknownRule : public CSSRule
-{
-public:
- CSSUnknownRule(StyleBase *parent) : CSSRule(parent) {}
-
- virtual bool isUnknownRule() { return true; }
-};
-
-} // namespace
-
-#endif
diff --git a/WebCore/css/css_valueimpl.cpp b/WebCore/css/css_valueimpl.cpp
deleted file mode 100644
index cca086b..0000000
--- a/WebCore/css/css_valueimpl.cpp
+++ /dev/null
@@ -1,1355 +0,0 @@
-/**
- * This file is part of the DOM implementation for KDE.
- *
- * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * 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 "css_valueimpl.h"
-
-#include "Cache.h"
-#include "CachedImage.h"
-#include "DocLoader.h"
-#include "Document.h"
-#include "ExceptionCode.h"
-#include "HTMLElement.h"
-#include "cssparser.h"
-#include "CSSPropertyNames.h"
-#include "cssstyleselector.h"
-#include "CSSStyleSheet.h"
-#include "CSSValueKeywords.h"
-#include "RegularExpression.h"
-
-#if SVG_SUPPORT
-#include "ksvgcssproperties.h"
-#endif
-
-// Not in any header, so just declare it here for now.
-WebCore::String getPropertyName(unsigned short id);
-
-namespace WebCore {
-
-// Defined in CSSGrammar.y, but not in any header, so just declare it here for now.
-int getPropertyID(const char* str, int len);
-
-static int propertyID(const String& s)
-{
- char buffer[maxCSSPropertyNameLength];
-
- unsigned len = s.length();
- if (len > maxCSSPropertyNameLength)
- return 0;
-
- for (unsigned i = 0; i != len; ++i) {
- UChar c = s[i];
- if (c == 0 || c >= 0x7F)
- return 0; // illegal character
- buffer[i] = c;
- }
-
- int id = getPropertyID(buffer, len);
-#if SVG_SUPPORT
- if (id == 0)
- id = SVG::getSVGCSSPropertyID(buffer, len);
-#endif
- return id;
-}
-
-
-// Quotes the string if it needs quoting.
-// We use single quotes for now beause markup.cpp uses double quotes.
-static String quoteStringIfNeeded(const String &string)
-{
- // For now, just do this for strings that start with "#" to fix Korean font names that start with "#".
- // Post-Tiger, we should isLegalIdentifier instead after working out all the ancillary issues.
- if (string[0] != '#')
- return string;
-
- // FIXME: Also need to transform control characters into \ sequences.
- String s = string;
- s.replace('\\', "\\\\");
- s.replace('\'', "\\'");
- return "'" + s + "'";
-}
-
-CSSStyleDeclaration::CSSStyleDeclaration(CSSRule *parent)
- : StyleBase(parent)
-{
-}
-
-bool CSSStyleDeclaration::isStyleDeclaration()
-{
- return true;
-}
-
-PassRefPtr<CSSValue> CSSStyleDeclaration::getPropertyCSSValue(const String& propertyName)
-{
- int propID = propertyID(propertyName);
- if (!propID)
- return 0;
- return getPropertyCSSValue(propID);
-}
-
-String CSSStyleDeclaration::getPropertyValue(const String &propertyName)
-{
- int propID = propertyID(propertyName);
- if (!propID)
- return String();
- return getPropertyValue(propID);
-}
-
-String CSSStyleDeclaration::getPropertyPriority(const String &propertyName)
-{
- int propID = propertyID(propertyName);
- if (!propID)
- return String();
- return getPropertyPriority(propID) ? "important" : "";
-}
-
-String CSSStyleDeclaration::getPropertyShorthand(const String &propertyName)
-{
- int propID = propertyID(propertyName);
- if (!propID)
- return String();
- int shorthandID = getPropertyShorthand(propID);
- if (!shorthandID)
- return String();
- return getPropertyName(shorthandID);
-}
-
-bool CSSStyleDeclaration::isPropertyImplicit(const String &propertyName)
-{
- int propID = propertyID(propertyName);
- if (!propID)
- return false;
- return isPropertyImplicit(propID);
-}
-
-void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
-{
- int propID = propertyID(propertyName);
- if (!propID) // set exception?
- return;
- bool important = priority.find("important", 0, false) != -1;
- setProperty(propID, value, important, ec);
-}
-
-String CSSStyleDeclaration::removeProperty(const String& propertyName, ExceptionCode& ec)
-{
- int propID = propertyID(propertyName);
- if (!propID)
- return String();
- return removeProperty(propID, ec);
-}
-
-bool CSSStyleDeclaration::isPropertyName(const String &propertyName)
-{
- return propertyID(propertyName);
-}
-
-// --------------------------------------------------------------------------------------
-
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration()
- : m_node(0)
-{
-}
-
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule *parent)
- : CSSStyleDeclaration(parent), m_node(0)
-{
-}
-
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule *parent, const DeprecatedValueList<CSSProperty> &values)
- : CSSStyleDeclaration(parent), m_values(values), m_node(0)
-{
- // FIXME: This allows duplicate properties.
-}
-
-CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule *parent, const CSSProperty * const *properties, int numProperties)
- : CSSStyleDeclaration(parent), m_node(0)
-{
- for (int i = 0; i < numProperties; ++i)
- m_values.append(*properties[i]);
- // FIXME: This allows duplicate properties.
-}
-
-CSSMutableStyleDeclaration& CSSMutableStyleDeclaration::operator=(const CSSMutableStyleDeclaration& o)
-{
- // don't attach it to the same node, just leave the current m_node value
- m_values = o.m_values;
- return *this;
-}
-
-String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const
-{
- RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
- if (value)
- return value->cssText();
-
- // Shorthand and 4-values properties
- switch ( propertyID ) {
- case CSS_PROP_BACKGROUND_POSITION:
- {
- // ## Is this correct? The code in cssparser.cpp is confusing
- const int properties[2] = { CSS_PROP_BACKGROUND_POSITION_X,
- CSS_PROP_BACKGROUND_POSITION_Y };
- return getShortHandValue( properties, 2 );
- }
- case CSS_PROP_BACKGROUND:
- {
- const int properties[5] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT,
- CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION,
- CSS_PROP_BACKGROUND_COLOR };
- return getShortHandValue( properties, 5 );
- }
- case CSS_PROP_BORDER:
- {
- const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE,
- CSS_PROP_BORDER_COLOR };
- return getShortHandValue( properties, 3 );
- }
- case CSS_PROP_BORDER_TOP:
- {
- const int properties[3] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_TOP_STYLE,
- CSS_PROP_BORDER_TOP_COLOR};
- return getShortHandValue( properties, 3 );
- }
- case CSS_PROP_BORDER_RIGHT:
- {
- const int properties[3] = { CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_RIGHT_STYLE,
- CSS_PROP_BORDER_RIGHT_COLOR};
- return getShortHandValue( properties, 3 );
- }
- case CSS_PROP_BORDER_BOTTOM:
- {
- const int properties[3] = { CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_BOTTOM_STYLE,
- CSS_PROP_BORDER_BOTTOM_COLOR};
- return getShortHandValue( properties, 3 );
- }
- case CSS_PROP_BORDER_LEFT:
- {
- const int properties[3] = { CSS_PROP_BORDER_LEFT_WIDTH, CSS_PROP_BORDER_LEFT_STYLE,
- CSS_PROP_BORDER_LEFT_COLOR};
- return getShortHandValue( properties, 3 );
- }
- case CSS_PROP_OUTLINE:
- {
- const int properties[3] = { CSS_PROP_OUTLINE_WIDTH, CSS_PROP_OUTLINE_STYLE,
- CSS_PROP_OUTLINE_COLOR };
- return getShortHandValue( properties, 3 );
- }
- case CSS_PROP_BORDER_COLOR:
- {
- const int properties[4] = { CSS_PROP_BORDER_TOP_COLOR, CSS_PROP_BORDER_RIGHT_COLOR,
- CSS_PROP_BORDER_BOTTOM_COLOR, CSS_PROP_BORDER_LEFT_COLOR };
- return get4Values( properties );
- }
- case CSS_PROP_BORDER_WIDTH:
- {
- const int properties[4] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_RIGHT_WIDTH,
- CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_LEFT_WIDTH };
- return get4Values( properties );
- }
- case CSS_PROP_BORDER_STYLE:
- {
- const int properties[4] = { CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_RIGHT_STYLE,
- CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_LEFT_STYLE };
- return get4Values( properties );
- }
- case CSS_PROP_MARGIN:
- {
- const int properties[4] = { CSS_PROP_MARGIN_TOP, CSS_PROP_MARGIN_RIGHT,
- CSS_PROP_MARGIN_BOTTOM, CSS_PROP_MARGIN_LEFT };
- return get4Values( properties );
- }
- case CSS_PROP_PADDING:
- {
- const int properties[4] = { CSS_PROP_PADDING_TOP, CSS_PROP_PADDING_RIGHT,
- CSS_PROP_PADDING_BOTTOM, CSS_PROP_PADDING_LEFT };
- return get4Values( properties );
- }
- case CSS_PROP_LIST_STYLE:
- {
- const int properties[3] = { CSS_PROP_LIST_STYLE_TYPE, CSS_PROP_LIST_STYLE_POSITION,
- CSS_PROP_LIST_STYLE_IMAGE };
- return getShortHandValue( properties, 3 );
- }
- }
- return String();
-}
-
-String CSSMutableStyleDeclaration::get4Values( const int* properties ) const
-{
- String res;
- for (int i = 0; i < 4; ++i) {
- if (!isPropertyImplicit(properties[i])) {
- RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
- if (!value) // apparently all 4 properties must be specified.
- return String();
- if (!res.isNull())
- res += " ";
- res += value->cssText();
- }
- }
- return res;
-}
-
-String CSSMutableStyleDeclaration::getShortHandValue( const int* properties, int number ) const
-{
- String res;
- for (int i = 0; i < number; ++i) {
- if (!isPropertyImplicit(properties[i])) {
- RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
- if (value) { // TODO provide default value if !value
- if (!res.isNull())
- res += " ";
- res += value->cssText();
- }
- }
- }
- return res;
-}
-
-PassRefPtr<CSSValue> CSSMutableStyleDeclaration::getPropertyCSSValue(int propertyID) const
-{
- DeprecatedValueListConstIterator<CSSProperty> end;
- for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.fromLast(); it != end; --it)
- if (propertyID == (*it).m_id)
- return (*it).value();
- return 0;
-}
-
-String CSSMutableStyleDeclaration::removeProperty(int propertyID, bool notifyChanged, ExceptionCode& ec)
-{
- ec = 0;
-
- String value;
-
- DeprecatedValueListIterator<CSSProperty> end;
- for (DeprecatedValueListIterator<CSSProperty> it = m_values.fromLast(); it != end; --it)
- if (propertyID == (*it).m_id) {
- value = (*it).value()->cssText();
- m_values.remove(it);
- if (notifyChanged)
- setChanged();
- break;
- }
-
- return value;
-}
-
-void CSSMutableStyleDeclaration::clear()
-{
- m_values.clear();
- setChanged();
-}
-
-void CSSMutableStyleDeclaration::setChanged()
-{
- if (m_node) {
- m_node->setChanged();
- // FIXME: Ideally, this should be factored better and there
- // should be a subclass of CSSMutableStyleDeclaration just
- // for inline style declarations that handles this
- if (m_node->isStyledElement() && this == static_cast<StyledElement *>(m_node)->inlineStyleDecl())
- static_cast<StyledElement *>(m_node)->invalidateStyleAttribute();
- return;
- }
-
- // ### quick&dirty hack for KDE 3.0... make this MUCH better! (Dirk)
- StyleBase *root = this;
- while (StyleBase *parent = root->parent())
- root = parent;
- if (root->isCSSStyleSheet())
- static_cast<CSSStyleSheet*>(root)->doc()->updateStyleSelector();
-}
-
-bool CSSMutableStyleDeclaration::getPropertyPriority(int propertyID) const
-{
- DeprecatedValueListConstIterator<CSSProperty> end;
- for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
- if (propertyID == (*it).id())
- return (*it).isImportant();
- return false;
-}
-
-int CSSMutableStyleDeclaration::getPropertyShorthand(int propertyID) const
-{
- DeprecatedValueListConstIterator<CSSProperty> end;
- for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
- if (propertyID == (*it).id())
- return (*it).shorthandID();
- return false;
-}
-
-bool CSSMutableStyleDeclaration::isPropertyImplicit(int propertyID) const
-{
- DeprecatedValueListConstIterator<CSSProperty> end;
- for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
- if (propertyID == (*it).id())
- return (*it).isImplicit();
- return false;
-}
-
-void CSSMutableStyleDeclaration::setProperty(int propertyID, const String &value, bool important, ExceptionCode& ec)
-{
- setProperty(propertyID, value, important, true, ec);
-}
-
-String CSSMutableStyleDeclaration::removeProperty(int propertyID, ExceptionCode& ec)
-{
- return removeProperty(propertyID, true, ec);
-}
-
-bool CSSMutableStyleDeclaration::setProperty(int propertyID, const String &value, bool important, bool notifyChanged, ExceptionCode& ec)
-{
- ec = 0;
-
- removeProperty(propertyID);
-
- CSSParser parser(useStrictParsing());
- bool success = parser.parseValue(this, propertyID, value, important);
- if (!success) {
- ec = SYNTAX_ERR;
- } else if (notifyChanged)
- setChanged();
- return success;
-}
-
-bool CSSMutableStyleDeclaration::setProperty(int propertyID, int value, bool important, bool notifyChanged)
-{
- removeProperty(propertyID);
- m_values.append(CSSProperty(propertyID, new CSSPrimitiveValue(value), important));
- if (notifyChanged)
- setChanged();
- return true;
-}
-
-void CSSMutableStyleDeclaration::setStringProperty(int propertyId, const String &value, CSSPrimitiveValue::UnitTypes type, bool important)
-{
- removeProperty(propertyId);
- m_values.append(CSSProperty(propertyId, new CSSPrimitiveValue(value, type), important));
- setChanged();
-}
-
-void CSSMutableStyleDeclaration::setImageProperty(int propertyId, const String &URL, bool important)
-{
- removeProperty(propertyId);
- m_values.append(CSSProperty(propertyId, new CSSImageValue(URL, this), important));
- setChanged();
-}
-
-void CSSMutableStyleDeclaration::parseDeclaration(const String &styleDeclaration)
-{
- m_values.clear();
- CSSParser parser(useStrictParsing());
- parser.parseDeclaration(this, styleDeclaration);
- setChanged();
-}
-
-void CSSMutableStyleDeclaration::addParsedProperties(const CSSProperty * const *properties, int numProperties)
-{
- for (int i = 0; i < numProperties; ++i) {
- removeProperty(properties[i]->id(), false);
- m_values.append(*properties[i]);
- }
- // FIXME: This probably should have a call to setChanged() if something changed. We may also wish to add
- // a notifyChanged argument to this function to follow the model of other functions in this class.
-}
-
-void CSSMutableStyleDeclaration::setLengthProperty(int id, const String &value, bool important, bool /* multiLength*/)
-{
- bool parseMode = useStrictParsing();
- setStrictParsing(false);
- setProperty(id, value, important);
- setStrictParsing(parseMode);
-}
-
-unsigned CSSMutableStyleDeclaration::length() const
-{
- return m_values.count();
-}
-
-String CSSMutableStyleDeclaration::item(unsigned i) const
-{
- if (i >= m_values.count())
- return String();
- return getPropertyName(m_values[i].id());
-}
-
-CSSRule *CSSStyleDeclaration::parentRule() const
-{
- return (parent() && parent()->isRule()) ? static_cast<CSSRule *>(parent()) : 0;
-}
-
-String CSSMutableStyleDeclaration::cssText() const
-{
- String result = "";
-
- DeprecatedValueListConstIterator<CSSProperty> end;
- for (DeprecatedValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
- result += (*it).cssText();
-
- return result;
-}
-
-void CSSMutableStyleDeclaration::setCssText(const String& text, ExceptionCode& ec)
-{
- ec = 0;
- m_values.clear();
- CSSParser parser(useStrictParsing());
- parser.parseDeclaration(this, text);
- // FIXME: Detect syntax errors and set ec.
- setChanged();
-}
-
-void CSSMutableStyleDeclaration::merge(CSSMutableStyleDeclaration *other, bool argOverridesOnConflict)
-{
- DeprecatedValueListConstIterator<CSSProperty> end;
- for (DeprecatedValueListConstIterator<CSSProperty> it = other->valuesIterator(); it != end; ++it) {
- const CSSProperty &property = *it;
- RefPtr<CSSValue> value = getPropertyCSSValue(property.id());
- if (value) {
- if (!argOverridesOnConflict)
- continue;
- removeProperty(property.id());
- }
- m_values.append(property);
- }
- // FIXME: This probably should have a call to setChanged() if something changed. We may also wish to add
- // a notifyChanged argument to this function to follow the model of other functions in this class.
-}
-
-void CSSStyleDeclaration::diff(CSSMutableStyleDeclaration *style) const
-{
- if (!style)
- return;
-
- DeprecatedValueList<int> properties;
- DeprecatedValueListConstIterator<CSSProperty> end;
- for (DeprecatedValueListConstIterator<CSSProperty> it(style->valuesIterator()); it != end; ++it) {
- const CSSProperty &property = *it;
- RefPtr<CSSValue> value = getPropertyCSSValue(property.id());
- if (value && (value->cssText() == property.value()->cssText()))
- properties.append(property.id());
- }
-
- for (DeprecatedValueListIterator<int> it(properties.begin()); it != properties.end(); ++it)
- style->removeProperty(*it);
-}
-
-// This is the list of properties we want to copy in the copyInheritableProperties() function.
-// It is the intersection of the list of inherited CSS properties and the
-// properties for which we have a computed implementation in this file.
-const int inheritableProperties[] = {
- CSS_PROP_BORDER_COLLAPSE,
- CSS_PROP_BORDER_SPACING,
- CSS_PROP_COLOR,
- CSS_PROP_FONT_FAMILY,
- CSS_PROP_FONT_SIZE,
- CSS_PROP_FONT_STYLE,
- CSS_PROP_FONT_VARIANT,
- CSS_PROP_FONT_WEIGHT,
- CSS_PROP_LETTER_SPACING,
- CSS_PROP_LINE_HEIGHT,
- CSS_PROP_TEXT_ALIGN,
- CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT,
- CSS_PROP_TEXT_INDENT,
- CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST,
- CSS_PROP_TEXT_TRANSFORM,
- CSS_PROP_ORPHANS,
- CSS_PROP_WHITE_SPACE,
- CSS_PROP_WIDOWS,
- CSS_PROP_WORD_SPACING,
-};
-
-const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]);
-
-// This is the list of properties we want to copy in the copyBlockProperties() function.
-// It is the list of CSS properties that apply specially to block-level elements.
-static const int blockProperties[] = {
- CSS_PROP_ORPHANS,
- CSS_PROP_OVERFLOW, // This can be also be applied to replaced elements
- CSS_PROP_PAGE_BREAK_AFTER,
- CSS_PROP_PAGE_BREAK_BEFORE,
- CSS_PROP_PAGE_BREAK_INSIDE,
- CSS_PROP_TEXT_ALIGN,
- CSS_PROP_TEXT_INDENT,
- CSS_PROP_WIDOWS
-};
-
-const unsigned numBlockProperties = sizeof(blockProperties) / sizeof(blockProperties[0]);
-
-PassRefPtr<CSSMutableStyleDeclaration> CSSMutableStyleDeclaration::copyBlockProperties() const
-{
- return copyPropertiesInSet(blockProperties, numBlockProperties);
-}
-
-void CSSMutableStyleDeclaration::removeBlockProperties()
-{
- removePropertiesInSet(blockProperties, numBlockProperties);
-}
-
-void CSSMutableStyleDeclaration::removeInheritableProperties()
-{
- removePropertiesInSet(inheritableProperties, numInheritableProperties);
-}
-
-PassRefPtr<CSSMutableStyleDeclaration> CSSStyleDeclaration::copyPropertiesInSet(const int *set, unsigned length) const
-{
- DeprecatedValueList<CSSProperty> list;
- for (unsigned i = 0; i < length; i++) {
- RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
- if (value)
- list.append(CSSProperty(set[i], value.release(), false));
- }
- return new CSSMutableStyleDeclaration(0, list);
-}
-
-void CSSMutableStyleDeclaration::removePropertiesInSet(const int *set, unsigned length)
-{
- bool changed = false;
- for (unsigned i = 0; i < length; i++) {
- RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
- if (value) {
- m_values.remove(CSSProperty(set[i], value.release(), false));
- changed = true;
- }
- }
- if (changed)
- setChanged();
-}
-
-PassRefPtr<CSSMutableStyleDeclaration> CSSMutableStyleDeclaration::makeMutable()
-{
- return this;
-}
-
-PassRefPtr<CSSMutableStyleDeclaration> CSSMutableStyleDeclaration::copy() const
-{
- return new CSSMutableStyleDeclaration(0, m_values);
-}
-
-// --------------------------------------------------------------------------------------
-
-unsigned short CSSInheritedValue::cssValueType() const
-{
- return CSS_INHERIT;
-}
-
-String CSSInheritedValue::cssText() const
-{
- return "inherit";
-}
-
-unsigned short CSSInitialValue::cssValueType() const
-{
- return CSS_INITIAL;
-}
-
-String CSSInitialValue::cssText() const
-{
- return "initial";
-}
-
-// ----------------------------------------------------------------------------------------
-
-CSSValueList::~CSSValueList()
-{
- for (CSSValue *val = m_values.first(); val; val = m_values.next())
- val->deref();
-}
-
-unsigned short CSSValueList::cssValueType() const
-{
- return CSS_VALUE_LIST;
-}
-
-void CSSValueList::append(PassRefPtr<CSSValue> val)
-{
- m_values.append(val.release());
-}
-
-String CSSValueList::cssText() const
-{
- String result = "";
-
- for (DeprecatedPtrListIterator<CSSValue> iterator(m_values); iterator.current(); ++iterator) {
- if (!result.isEmpty())
- result += ", ";
- result += iterator.current()->cssText();
- }
-
- return result;
-}
-
-// -------------------------------------------------------------------------------------
-
-CSSPrimitiveValue::CSSPrimitiveValue()
-{
- m_type = 0;
-}
-
-CSSPrimitiveValue::CSSPrimitiveValue(int ident)
-{
- m_value.ident = ident;
- m_type = CSS_IDENT;
-}
-
-CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitTypes type)
-{
- m_value.num = num;
- m_type = type;
-}
-
-CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitTypes type)
-{
- if ((m_value.string = str.impl()))
- m_value.string->ref();
- m_type = type;
-}
-
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<Counter> c)
-{
- m_value.counter = c.release();
- m_type = CSS_COUNTER;
-}
-
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<RectImpl> r)
-{
- m_value.rect = r.release();
- m_type = CSS_RECT;
-}
-
-#if __APPLE__
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<DashboardRegion> r)
-{
- m_value.region = r.release();
- m_type = CSS_DASHBOARD_REGION;
-}
-#endif
-
-CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color)
-{
- m_value.rgbcolor = color;
- m_type = CSS_RGBCOLOR;
-}
-
-CSSPrimitiveValue::CSSPrimitiveValue(PassRefPtr<Pair> p)
-{
- m_value.pair = p.release();
- m_type = CSS_PAIR;
-}
-
-CSSPrimitiveValue::~CSSPrimitiveValue()
-{
- cleanup();
-}
-
-void CSSPrimitiveValue::cleanup()
-{
- switch(m_type) {
- case CSS_STRING:
- case CSS_URI:
- case CSS_ATTR:
- if (m_value.string)
- m_value.string->deref();
- break;
- case CSS_COUNTER:
- m_value.counter->deref();
- break;
- case CSS_RECT:
- m_value.rect->deref();
- break;
- case CSS_PAIR:
- m_value.pair->deref();
- break;
-#if __APPLE__
- case CSS_DASHBOARD_REGION:
- if (m_value.region)
- m_value.region->deref();
- break;
-#endif
- default:
- break;
- }
-
- m_type = 0;
-}
-
-int CSSPrimitiveValue::computeLengthInt(RenderStyle *style)
-{
- double result = computeLengthFloat(style);
-
- // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
- // need to go ahead and round if we're really close to the next integer value.
- result += result < 0 ? -0.01 : +0.01;
-
- if (result > INT_MAX || result < INT_MIN)
- return 0;
- return (int)result;
-}
-
-int CSSPrimitiveValue::computeLengthInt(RenderStyle *style, double multiplier)
-{
- double result = multiplier * computeLengthFloat(style);
-
- // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
- // need to go ahead and round if we're really close to the next integer value.
- result += result < 0 ? -0.01 : +0.01;
-
- if (result > INT_MAX || result < INT_MIN)
- return 0;
- return (int)result;
-}
-
-const int intMaxForLength = 0x7ffffff; // max value for a 28-bit int
-const int intMinForLength = (-0x7ffffff-1); // min value for a 28-bit int
-
-// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
-int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle *style)
-{
- double result = computeLengthFloat(style);
-
- // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
- // need to go ahead and round if we're really close to the next integer value.
- result += result < 0 ? -0.01 : +0.01;
-
- if (result > intMaxForLength || result < intMinForLength)
- return 0;
- return (int)result;
-}
-
-// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
-int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle *style, double multiplier)
-{
- double result = multiplier * computeLengthFloat(style);
-
- // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
- // need to go ahead and round if we're really close to the next integer value.
- result += result < 0 ? -0.01 : +0.01;
-
- if (result > intMaxForLength || result < intMinForLength)
- return 0;
- return (int)result;
-}
-
-short CSSPrimitiveValue::computeLengthShort(RenderStyle *style)
-{
- double result = computeLengthFloat(style);
-
- // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
- // need to go ahead and round if we're really close to the next integer value.
- result += result < 0 ? -0.01 : +0.01;
-
- if (result > SHRT_MAX || result < SHRT_MIN)
- return 0;
- return (short)result;
-}
-
-short CSSPrimitiveValue::computeLengthShort(RenderStyle *style, double multiplier)
-{
- double result = multiplier * computeLengthFloat(style);
-
- // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
- // need to go ahead and round if we're really close to the next integer value.
- result += result < 0 ? -0.01 : +0.01;
-
- if (result > SHRT_MAX || result < SHRT_MIN)
- return 0;
- return (short)result;
-}
-
-double CSSPrimitiveValue::computeLengthFloat(RenderStyle *style, bool applyZoomFactor)
-{
- unsigned short type = primitiveType();
-
- // We always assume 96 CSS pixels in a CSS inch. This is the cold hard truth of the Web.
- // At high DPI, we may scale a CSS pixel, but the ratio of the CSS pixel to the so-called
- // "absolute" CSS length units like inch and pt is always fixed and never changes.
- double cssPixelsPerInch = 96.;
-
- double factor = 1.;
- switch(type) {
- case CSS_EMS:
- factor = applyZoomFactor ?
- style->fontDescription().computedSize() :
- style->fontDescription().specifiedSize();
- break;
- case CSS_EXS: {
- // FIXME: We have a bug right now where the zoom will be applied multiple times to EX units.
- // We really need to compute EX using fontMetrics for the original specifiedSize and not use
- // our actual constructed rendering font.
- factor = style->font().xHeight();
- break;
- }
- case CSS_PX:
- break;
- case CSS_CM:
- factor = cssPixelsPerInch/2.54; // (2.54 cm/in)
- break;
- case CSS_MM:
- factor = cssPixelsPerInch/25.4;
- break;
- case CSS_IN:
- factor = cssPixelsPerInch;
- break;
- case CSS_PT:
- factor = cssPixelsPerInch/72.;
- break;
- case CSS_PC:
- // 1 pc == 12 pt
- factor = cssPixelsPerInch*12./72.;
- break;
- default:
- return -1;
- }
-
- return getFloatValue() * factor;
-}
-
-void CSSPrimitiveValue::setFloatValue( unsigned short unitType, double floatValue, ExceptionCode& ec)
-{
- ec = 0;
- cleanup();
- // ### check if property supports this type
- if (m_type > CSS_DIMENSION) {
- ec = SYNTAX_ERR;
- return;
- }
- //if(m_type > CSS_DIMENSION) throw DOMException(INVALID_ACCESS_ERR);
- m_value.num = floatValue;
- m_type = unitType;
-}
-
-double scaleFactorForConversion(unsigned short unitType)
-{
- double cssPixelsPerInch = 96.0;
- double factor = 1.0;
-
- switch(unitType) {
- case CSSPrimitiveValue::CSS_PX:
- break;
- case CSSPrimitiveValue::CSS_CM:
- factor = cssPixelsPerInch / 2.54; // (2.54 cm/in)
- break;
- case CSSPrimitiveValue::CSS_MM:
- factor = cssPixelsPerInch / 25.4;
- break;
- case CSSPrimitiveValue::CSS_IN:
- factor = cssPixelsPerInch;
- break;
- case CSSPrimitiveValue::CSS_PT:
- factor = cssPixelsPerInch / 72.0;
- break;
- case CSSPrimitiveValue::CSS_PC:
- factor = cssPixelsPerInch * 12.0 / 72.0; // 1 pc == 12 pt
- break;
- default:
- break;
- }
-
- return factor;
-}
-
-double CSSPrimitiveValue::getFloatValue(unsigned short unitType)
-{
- if (unitType == m_type || unitType < CSS_PX || unitType > CSS_PC)
- return m_value.num;
-
- double convertedValue = m_value.num;
-
- // First convert the value from m_type into CSSPixels
- double factor = scaleFactorForConversion(m_type);
- convertedValue *= factor;
-
- // Now convert from CSSPixels to the specified unitType
- factor = scaleFactorForConversion(unitType);
- convertedValue /= factor;
-
- return convertedValue;
-}
-
-void CSSPrimitiveValue::setStringValue( unsigned short stringType, const String &stringValue, ExceptionCode& ec)
-{
- ec = 0;
- cleanup();
- //if(m_type < CSS_STRING) throw DOMException(INVALID_ACCESS_ERR);
- //if(m_type > CSS_ATTR) throw DOMException(INVALID_ACCESS_ERR);
- if (m_type < CSS_STRING || m_type > CSS_ATTR) {
- ec = SYNTAX_ERR;
- return;
- }
- if (stringType != CSS_IDENT) {
- m_value.string = stringValue.impl();
- m_value.string->ref();
- m_type = stringType;
- }
- // ### parse ident
-}
-
-String CSSPrimitiveValue::getStringValue() const
-{
- switch (m_type) {
- case CSS_STRING:
- case CSS_ATTR:
- case CSS_URI:
- return m_value.string;
- case CSS_IDENT:
- return getValueName(m_value.ident);
- default:
- // FIXME: The CSS 2.1 spec says you should throw an exception here.
- break;
- }
-
- return String();
-}
-
-unsigned short CSSPrimitiveValue::cssValueType() const
-{
- return CSS_PRIMITIVE_VALUE;
-}
-
-bool CSSPrimitiveValue::parseString( const String &/*string*/, bool )
-{
- // ###
- return false;
-}
-
-int CSSPrimitiveValue::getIdent()
-{
- if(m_type != CSS_IDENT) return 0;
- return m_value.ident;
-}
-
-String CSSPrimitiveValue::cssText() const
-{
- // ### return the original value instead of a generated one (e.g. color
- // name if it was specified) - check what spec says about this
- String text;
- switch ( m_type ) {
- case CSS_UNKNOWN:
- // ###
- break;
- case CSS_NUMBER:
- text = String::number(m_value.num);
- break;
- case CSS_PERCENTAGE:
- text = String::number(m_value.num) + "%";
- break;
- case CSS_EMS:
- text = String::number(m_value.num) + "em";
- break;
- case CSS_EXS:
- text = String::number(m_value.num) + "ex";
- break;
- case CSS_PX:
- text = String::number(m_value.num) + "px";
- break;
- case CSS_CM:
- text = String::number(m_value.num) + "cm";
- break;
- case CSS_MM:
- text = String::number(m_value.num) + "mm";
- break;
- case CSS_IN:
- text = String::number(m_value.num) + "in";
- break;
- case CSS_PT:
- text = String::number(m_value.num) + "pt";
- break;
- case CSS_PC:
- text = String::number(m_value.num) + "pc";
- break;
- case CSS_DEG:
- text = String::number(m_value.num) + "deg";
- break;
- case CSS_RAD:
- text = String::number(m_value.num) + "rad";
- break;
- case CSS_GRAD:
- text = String::number(m_value.num) + "grad";
- break;
- case CSS_MS:
- text = String::number(m_value.num) + "ms";
- break;
- case CSS_S:
- text = String::number(m_value.num) + "s";
- break;
- case CSS_HZ:
- text = String::number(m_value.num) + "hz";
- break;
- case CSS_KHZ:
- text = String::number(m_value.num) + "khz";
- break;
- case CSS_DIMENSION:
- // ###
- break;
- case CSS_STRING:
- text = quoteStringIfNeeded(m_value.string);
- break;
- case CSS_URI:
- text = "url(" + String(m_value.string) + ")";
- break;
- case CSS_IDENT:
- text = getValueName(m_value.ident);
- break;
- case CSS_ATTR:
- // ###
- break;
- case CSS_COUNTER:
- // ###
- break;
- case CSS_RECT: {
- RectImpl* rectVal = getRectValue();
- text = "rect(";
- text += rectVal->top()->cssText() + " ";
- text += rectVal->right()->cssText() + " ";
- text += rectVal->bottom()->cssText() + " ";
- text += rectVal->left()->cssText() + ")";
- break;
- }
- case CSS_RGBCOLOR: {
- Color color(m_value.rgbcolor);
- if (color.alpha() < 0xFF)
- text = "rgba(";
- else
- text = "rgb(";
- text += String::number(color.red()) + ", ";
- text += String::number(color.green()) + ", ";
- text += String::number(color.blue());
- if (color.alpha() < 0xFF)
- text += ", " + String::number((float)color.alpha() / 0xFF);
- text += ")";
- break;
- }
- case CSS_PAIR:
- text = m_value.pair->first()->cssText();
- text += " ";
- text += m_value.pair->second()->cssText();
- break;
-#if __APPLE__
- case CSS_DASHBOARD_REGION:
- for (DashboardRegion* region = getDashboardRegionValue(); region; region = region->m_next.get()) {
- text = "dashboard-region(";
- text += region->m_label;
- if (region->m_isCircle)
- text += " circle ";
- else if (region->m_isRectangle)
- text += " rectangle ";
- else
- break;
- text += region->top()->cssText() + " ";
- text += region->right()->cssText() + " ";
- text += region->bottom()->cssText() + " ";
- text += region->left()->cssText();
- text += ")";
- }
- break;
-#endif
- }
- return text;
-}
-
-// -----------------------------------------------------------------
-
-RectImpl::~RectImpl()
-{
-}
-
-// -----------------------------------------------------------------
-
-Pair::~Pair()
-{
-}
-
-// -----------------------------------------------------------------
-
-CSSImageValue::CSSImageValue(const String& url, StyleBase *style)
- : CSSPrimitiveValue(url, CSS_URI), m_image(0), m_accessedImage(false)
-{
-}
-
-CSSImageValue::CSSImageValue()
- : CSSPrimitiveValue(CSS_VAL_NONE), m_image(0), m_accessedImage(true)
-{
-}
-
-CSSImageValue::~CSSImageValue()
-{
- if (m_image)
- m_image->deref(this);
-}
-
-CachedImage* CSSImageValue::image(DocLoader* loader)
-{
- if (!m_accessedImage) {
- m_accessedImage = true;
-
- if (loader)
- m_image = loader->requestImage(getStringValue());
- else
- m_image = Cache::requestImage(0, getStringValue());
-
- if (m_image)
- m_image->ref(this);
- }
-
- return m_image;
-}
-
-// ------------------------------------------------------------------------
-
-CSSBorderImageValue::CSSBorderImageValue(PassRefPtr<CSSImageValue> image,
- PassRefPtr<RectImpl> imageRect, int horizontalRule, int verticalRule)
- : m_image(image), m_imageSliceRect(imageRect)
- , m_horizontalSizeRule(horizontalRule), m_verticalSizeRule(verticalRule)
-{
-}
-
-String CSSBorderImageValue::cssText() const
-{
- // Image first.
- String text(m_image->cssText());
- text += " ";
-
- // Now the rect, but it isn't really a rect, so we dump manually
- text += m_imageSliceRect->top()->cssText();
- text += " ";
- text += m_imageSliceRect->right()->cssText();
- text += " ";
- text += m_imageSliceRect->bottom()->cssText();
- text += " ";
- text += m_imageSliceRect->left()->cssText();
-
- // Now the keywords.
- text += " ";
- text += CSSPrimitiveValue(m_horizontalSizeRule).cssText();
- text += " ";
- text += CSSPrimitiveValue(m_verticalSizeRule).cssText();
-
- return text;
-}
-
-// ------------------------------------------------------------------------
-
-FontFamilyValue::FontFamilyValue(const DeprecatedString& string)
- : CSSPrimitiveValue(String(), CSS_STRING)
-{
- static const RegularExpression parenReg(" \\(.*\\)$");
- static const RegularExpression braceReg(" \\[.*\\]$");
-
- parsedFontName = string;
- // a language tag is often added in braces at the end. Remove it.
- parsedFontName.replace(parenReg, "");
- // remove [Xft] qualifiers
- parsedFontName.replace(braceReg, "");
-}
-
-String FontFamilyValue::cssText() const
-{
- return quoteStringIfNeeded(parsedFontName);
-}
-
-String FontValue::cssText() const
-{
- // font variant weight size / line-height family
-
- String result("");
-
- if (style) {
- result += style->cssText();
- }
- if (variant) {
- if (!result.isEmpty())
- result += " ";
- result += variant->cssText();
- }
- if (weight) {
- if (!result.isEmpty())
- result += " ";
- result += weight->cssText();
- }
- if (size) {
- if (!result.isEmpty())
- result += " ";
- result += size->cssText();
- }
- if (lineHeight) {
- if (!size)
- result += " ";
- result += "/";
- result += lineHeight->cssText();
- }
- if (family) {
- if (!result.isEmpty())
- result += " ";
- result += family->cssText();
- }
-
- return result;
-}
-
-
-// Used for text-shadow and box-shadow
-ShadowValue::ShadowValue(PassRefPtr<CSSPrimitiveValue> _x,
- PassRefPtr<CSSPrimitiveValue> _y,
- PassRefPtr<CSSPrimitiveValue> _blur,
- PassRefPtr<CSSPrimitiveValue> _color)
- : x(_x), y(_y), blur(_blur), color(_color)
-{
-}
-
-String ShadowValue::cssText() const
-{
- String text("");
-
- if (color)
- text += color->cssText();
- if (x) {
- if (!text.isEmpty())
- text += " ";
- text += x->cssText();
- }
- if (y) {
- if (!text.isEmpty())
- text += " ";
- text += y->cssText();
- }
- if (blur) {
- if (!text.isEmpty())
- text += " ";
- text += blur->cssText();
- }
-
- return text;
-}
-
-String CSSProperty::cssText() const
-{
- return getPropertyName(id()) + ": " + m_value->cssText()
- + (isImportant() ? " !important" : "") + "; ";
-}
-
-bool operator==(const CSSProperty &a, const CSSProperty &b)
-{
- return a.m_id == b.m_id && a.m_important == b.m_important && a.m_value == b.m_value;
-}
-
-}
diff --git a/WebCore/css/css_valueimpl.h b/WebCore/css/css_valueimpl.h
deleted file mode 100644
index 7020f1b..0000000
--- a/WebCore/css/css_valueimpl.h
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * 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.
- */
-
-#ifndef CSS_css_valueimpl_h_
-#define CSS_css_valueimpl_h_
-
-#include "CachedObjectClient.h"
-#include "css_base.h"
-#include "DeprecatedPtrList.h"
-#include "DeprecatedString.h"
-#include "DeprecatedValueList.h"
-#include <wtf/PassRefPtr.h>
-
-class QPaintDeviceMetrics;
-
-namespace WebCore {
-
-class CSSMutableStyleDeclaration;
-class CachedImage;
-class Counter;
-class DocLoader;
-class Node;
-class Pair;
-class RectImpl;
-class RenderStyle;
-
-#if __APPLE__
-class DashboardRegion;
-#endif
-
-typedef int ExceptionCode;
-
-extern const int inheritableProperties[];
-extern const unsigned numInheritableProperties;
-
-class CSSStyleDeclaration : public StyleBase {
-public:
- virtual bool isStyleDeclaration();
-
- static bool isPropertyName(const String& propertyName);
-
- CSSRule* parentRule() const;
-
- virtual String cssText() const = 0;
- virtual void setCssText(const String&, ExceptionCode&) = 0;
-
- virtual unsigned length() const = 0;
- virtual String item(unsigned index) const = 0;
-
- PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
- String getPropertyValue(const String& propertyName);
- String getPropertyPriority(const String& propertyName);
- String getPropertyShorthand(const String& propertyName);
- bool isPropertyImplicit(const String& propertyName);
-
- virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const = 0;
- virtual String getPropertyValue(int propertyID) const = 0;
- virtual bool getPropertyPriority(int propertyID) const = 0;
- virtual int getPropertyShorthand(int propertyID) const = 0;
- virtual bool isPropertyImplicit(int propertyID) const = 0;
-
- void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
- String removeProperty(const String& propertyName, ExceptionCode&);
- virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&) = 0;
- virtual String removeProperty(int propertyID, ExceptionCode&) = 0;
-
- virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const = 0;
- virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable() = 0;
-
- void diff(CSSMutableStyleDeclaration*) const;
-
- PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
-
-protected:
- CSSStyleDeclaration(CSSRule* parentRule = 0);
-
-private:
- CSSStyleDeclaration(const CSSStyleDeclaration &);
- CSSStyleDeclaration& operator=(const CSSStyleDeclaration &);
-};
-
-class CSSValue : public StyleBase
-{
-public:
- enum UnitTypes {
- CSS_INHERIT = 0,
- CSS_PRIMITIVE_VALUE = 1,
- CSS_VALUE_LIST = 2,
- CSS_CUSTOM = 3,
- CSS_INITIAL = 4
- };
-
- CSSValue() : StyleBase(0) { }
-
- virtual unsigned short cssValueType() const { return CSS_CUSTOM; }
- virtual String cssText() const = 0;
- void setCssText(const String&) { } // FIXME: Not implemented.
-
- virtual bool isValue() { return true; }
- virtual bool isFontValue() { return false; }
-};
-
-class CSSInheritedValue : public CSSValue
-{
-public:
- virtual unsigned short cssValueType() const;
- virtual String cssText() const;
-};
-
-class CSSInitialValue : public CSSValue
-{
-public:
- virtual unsigned short cssValueType() const;
- virtual String cssText() const;
-};
-
-class CSSValueList : public CSSValue
-{
-public:
- virtual ~CSSValueList();
-
- unsigned length() const { return m_values.count(); }
- CSSValue* item (unsigned index) { return m_values.at(index); }
-
- virtual bool isValueList() { return true; }
-
- virtual unsigned short cssValueType() const;
-
- void append(PassRefPtr<CSSValue>);
- virtual String cssText() const;
-
-protected:
- DeprecatedPtrList<CSSValue> m_values;
-};
-
-
-class CSSPrimitiveValue : public CSSValue
-{
-public:
- enum UnitTypes {
- CSS_UNKNOWN = 0,
- CSS_NUMBER = 1,
- CSS_PERCENTAGE = 2,
- CSS_EMS = 3,
- CSS_EXS = 4,
- CSS_PX = 5,
- CSS_CM = 6,
- CSS_MM = 7,
- CSS_IN = 8,
- CSS_PT = 9,
- CSS_PC = 10,
- CSS_DEG = 11,
- CSS_RAD = 12,
- CSS_GRAD = 13,
- CSS_MS = 14,
- CSS_S = 15,
- CSS_HZ = 16,
- CSS_KHZ = 17,
- CSS_DIMENSION = 18,
- CSS_STRING = 19,
- CSS_URI = 20,
- CSS_IDENT = 21,
- CSS_ATTR = 22,
- CSS_COUNTER = 23,
- CSS_RECT = 24,
- CSS_RGBCOLOR = 25,
- CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
- CSS_DASHBOARD_REGION = 101 // FIXME: What on earth is this doing as a primitive value? It should not be!
- };
-
- // FIXME: int vs. unsigned overloading is too tricky for color vs. ident
- CSSPrimitiveValue();
- CSSPrimitiveValue(int ident);
- CSSPrimitiveValue(double, UnitTypes);
- CSSPrimitiveValue(const String&, UnitTypes);
- CSSPrimitiveValue(PassRefPtr<Counter>);
- CSSPrimitiveValue(PassRefPtr<RectImpl>);
- CSSPrimitiveValue(unsigned color); // RGB value
- CSSPrimitiveValue(PassRefPtr<Pair>);
-
-#if __APPLE__
- CSSPrimitiveValue(PassRefPtr<DashboardRegion>); // FIXME: Why is dashboard region a primitive value? This makes no sense.
-#endif
-
- virtual ~CSSPrimitiveValue();
-
- void cleanup();
-
- unsigned short primitiveType() const { return m_type; }
-
- /*
- * computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
- * the fontinfo in case val is defined in em or ex.
- *
- * The metrics have to be a bit different for screen and printer output.
- * For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
- *
- * this is screen/printer dependent, so we probably need a config option for this,
- * and some tool to calibrate.
- */
- int computeLengthInt(RenderStyle*);
- int computeLengthInt(RenderStyle*, double multiplier);
- int computeLengthIntForLength(RenderStyle*);
- int computeLengthIntForLength(RenderStyle*, double multiplier);
- short computeLengthShort(RenderStyle*);
- short computeLengthShort(RenderStyle*, double multiplier);
- double computeLengthFloat(RenderStyle*, bool applyZoomFactor = true);
-
- // use with care!!!
- void setPrimitiveType(unsigned short type) { m_type = type; }
- void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&);
- double getFloatValue(unsigned short unitType);
- double getFloatValue() { return m_value.num; }
-
- void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&);
- String getStringValue() const;
-
- Counter* getCounterValue () const {
- return m_type != CSS_COUNTER ? 0 : m_value.counter;
- }
-
- RectImpl* getRectValue () const {
- return m_type != CSS_RECT ? 0 : m_value.rect;
- }
-
- unsigned getRGBColorValue() const {
- return m_type != CSS_RGBCOLOR ? 0 : m_value.rgbcolor;
- }
-
- Pair* getPairValue() const {
- return m_type != CSS_PAIR ? 0 : m_value.pair;
- }
-
-#if __APPLE__
- DashboardRegion *getDashboardRegionValue () const {
- return m_type != CSS_DASHBOARD_REGION ? 0 : m_value.region;
- }
-#endif
-
- virtual bool isPrimitiveValue() const { return true; }
- virtual unsigned short cssValueType() const;
-
- int getIdent();
-
- virtual bool parseString(const String&, bool = false);
- virtual String cssText() const;
-
- virtual bool isQuirkValue() { return false; }
-
-protected:
- int m_type;
- union {
- int ident;
- double num;
- StringImpl* string;
- Counter* counter;
- RectImpl* rect;
- unsigned rgbcolor;
- Pair* pair;
-#if __APPLE__
- DashboardRegion* region;
-#endif
- } m_value;
-};
-
-// This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
-// The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em
-// in a stylesheet. When the quirky value is used, if you're in quirks mode, the margin will
-// collapse away inside a table cell.
-class CSSQuirkPrimitiveValue : public CSSPrimitiveValue
-{
-public:
- CSSQuirkPrimitiveValue(double num, UnitTypes type)
- : CSSPrimitiveValue(num, type) {}
-
- virtual bool isQuirkValue() { return true; }
-};
-
-class Counter : public Shared<Counter> {
-public:
- String identifier() const { return m_identifier; }
- String listStyle() const { return m_listStyle; }
- String separator() const { return m_separator; }
-
- String m_identifier;
- String m_listStyle;
- String m_separator;
-};
-
-class RectImpl : public Shared<RectImpl> {
-public:
- virtual ~RectImpl();
-
- CSSPrimitiveValue* top() const { return m_top.get(); }
- CSSPrimitiveValue* right() const { return m_right.get(); }
- CSSPrimitiveValue* bottom() const { return m_bottom.get(); }
- CSSPrimitiveValue* left() const { return m_left.get(); }
-
- void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
- void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; }
- void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
- void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
-
-protected:
- RefPtr<CSSPrimitiveValue> m_top;
- RefPtr<CSSPrimitiveValue> m_right;
- RefPtr<CSSPrimitiveValue> m_bottom;
- RefPtr<CSSPrimitiveValue> m_left;
-};
-
-// A primitive value representing a pair. This is useful for properties like border-radius, background-size/position,
-// and border-spacing (all of which are space-separated sets of two values). At the moment we are only using it for
-// border-radius and background-size, but (FIXME) border-spacing and background-position could be converted over to use
-// it (eliminating some extra -webkit- internal properties).
-class Pair : public Shared<Pair> {
-public:
- Pair() : m_first(0), m_second(0) { }
- Pair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> second)
- : m_first(first), m_second(second) { }
- virtual ~Pair();
-
- CSSPrimitiveValue* first() const { return m_first.get(); }
- CSSPrimitiveValue* second() const { return m_second.get(); }
-
- void setFirst(PassRefPtr<CSSPrimitiveValue> first) { m_first = first; }
- void setSecond(PassRefPtr<CSSPrimitiveValue> second) { m_second = second; }
-
-protected:
- RefPtr<CSSPrimitiveValue> m_first;
- RefPtr<CSSPrimitiveValue> m_second;
-};
-
-class DashboardRegion : public RectImpl {
-public:
- DashboardRegion() : m_isCircle(0), m_isRectangle(0) { }
-
- RefPtr<DashboardRegion> m_next;
- String m_label;
- String m_geometryType;
- bool m_isCircle : 1;
- bool m_isRectangle : 1;
-};
-
-class CSSImageValue : public CSSPrimitiveValue, public CachedObjectClient
-{
-public:
- CSSImageValue();
- CSSImageValue(const String& url, StyleBase*);
- virtual ~CSSImageValue();
-
- CachedImage* image(DocLoader*);
-
-protected:
- CachedImage* m_image;
- bool m_accessedImage;
-};
-
-class CSSBorderImageValue : public CSSValue
-{
-public:
- CSSBorderImageValue();
- CSSBorderImageValue(PassRefPtr<CSSImageValue>,
- PassRefPtr<RectImpl>, int horizontalRule, int verticalRule);
-
- virtual String cssText() const;
-
-public:
- // The border image.
- RefPtr<CSSImageValue> m_image;
-
- // These four values are used to make "cuts" in the image. They can be numbers
- // or percentages.
- RefPtr<RectImpl> m_imageSliceRect;
-
- // Values for how to handle the scaling/stretching/tiling of the image slices.
- int m_horizontalSizeRule; // Rule for how to adjust the widths of the top/middle/bottom
- int m_verticalSizeRule; // Rule for how to adjust the heights of the left/middle/right
-};
-
-class FontFamilyValue : public CSSPrimitiveValue
-{
-public:
- FontFamilyValue( const DeprecatedString &string);
- const DeprecatedString& fontName() const { return parsedFontName; }
- int genericFamilyType() const { return _genericFamilyType; }
-
- virtual String cssText() const;
-
- DeprecatedString parsedFontName;
-private:
- int _genericFamilyType;
-};
-
-class FontValue : public CSSValue
-{
-public:
- virtual String cssText() const;
-
- virtual bool isFontValue() { return true; }
-
- RefPtr<CSSPrimitiveValue> style;
- RefPtr<CSSPrimitiveValue> variant;
- RefPtr<CSSPrimitiveValue> weight;
- RefPtr<CSSPrimitiveValue> size;
- RefPtr<CSSPrimitiveValue> lineHeight;
- RefPtr<CSSValueList> family;
-};
-
-// Used for text-shadow and box-shadow
-class ShadowValue : public CSSValue
-{
-public:
- ShadowValue(PassRefPtr<CSSPrimitiveValue> x,
- PassRefPtr<CSSPrimitiveValue> y,
- PassRefPtr<CSSPrimitiveValue> blur,
- PassRefPtr<CSSPrimitiveValue> color);
-
- virtual String cssText() const;
-
- RefPtr<CSSPrimitiveValue> x;
- RefPtr<CSSPrimitiveValue> y;
- RefPtr<CSSPrimitiveValue> blur;
- RefPtr<CSSPrimitiveValue> color;
-};
-
-// ------------------------------------------------------------------------------
-
-// another helper class
-class CSSProperty
-{
-public:
- CSSProperty(int propID, PassRefPtr<CSSValue> value, bool important = false, int shorthandID = 0, bool implicit = false)
- : m_id(propID), m_shorthandID(shorthandID), m_important(important), m_implicit(implicit), m_value(value)
- {
- }
-
- CSSProperty &operator=(const CSSProperty& o)
- {
- m_id = o.m_id;
- m_shorthandID = o.m_shorthandID;
- m_important = o.m_important;
- m_value = o.m_value;
- return *this;
- }
-
- int id() const { return m_id; }
- int shorthandID() const { return m_shorthandID; }
-
- bool isImportant() const { return m_important; }
- bool isImplicit() const { return m_implicit; }
-
- CSSValue* value() const { return m_value.get(); }
-
- String cssText() const;
-
- // make sure the following fits in 4 bytes.
- int m_id;
- int m_shorthandID; // If this property was set as part of a shorthand, gives the shorthand.
- bool m_important : 1;
- bool m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
-
- friend bool operator==(const CSSProperty &, const CSSProperty &);
-
- RefPtr<CSSValue> m_value;
-};
-
-class CSSMutableStyleDeclaration : public CSSStyleDeclaration
-{
-public:
- CSSMutableStyleDeclaration();
- CSSMutableStyleDeclaration(CSSRule* parentRule);
- CSSMutableStyleDeclaration(CSSRule* parentRule, const DeprecatedValueList<CSSProperty> &);
- CSSMutableStyleDeclaration(CSSRule* parentRule, const CSSProperty * const *, int numProperties);
-
- CSSMutableStyleDeclaration &operator=(const CSSMutableStyleDeclaration &);
-
- void setNode(Node* node) { m_node = node; }
-
- virtual String cssText() const;
- virtual void setCssText(const String&, ExceptionCode&);
-
- virtual unsigned length() const;
- virtual String item(unsigned index) const;
-
- virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
- virtual String getPropertyValue(int propertyID) const;
- virtual bool getPropertyPriority(int propertyID) const;
- virtual int getPropertyShorthand(int propertyID) const;
- virtual bool isPropertyImplicit(int propertyID) const;
-
- virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
- virtual String removeProperty(int propertyID, ExceptionCode&);
-
- virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
- virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
-
- DeprecatedValueListConstIterator<CSSProperty> valuesIterator() const { return m_values.begin(); }
-
- bool setProperty(int propertyID, int value, bool important = false, bool notifyChanged = true);
- bool setProperty(int propertyID, const String& value, bool important, bool notifyChanged, ExceptionCode&);
- bool setProperty(int propertyId, const String& value, bool important = false, bool notifyChanged = true)
- { ExceptionCode ec; return setProperty(propertyId, value, important, notifyChanged, ec); }
-
- String removeProperty(int propertyID, bool notifyChanged, ExceptionCode&);
- String removeProperty(int propertyID, bool notifyChanged = true)
- { ExceptionCode ec; return removeProperty(propertyID, notifyChanged, ec); }
-
- void clear();
-
- void setChanged();
-
- // setLengthProperty treats integers as pixels! (Needed for conversion of HTML attributes.)
- void setLengthProperty(int propertyId, const String& value, bool important, bool multiLength = false);
- void setStringProperty(int propertyId, const String& value, CSSPrimitiveValue::UnitTypes, bool important = false); // parsed string value
- void setImageProperty(int propertyId, const String& URL, bool important = false);
-
- // The following parses an entire new style declaration.
- void parseDeclaration(const String& styleDeclaration);
-
- // Besides adding the properties, this also removes any existing properties with these IDs.
- // It does no notification since it's called by the parser.
- void addParsedProperties(const CSSProperty * const *, int numProperties);
-
- PassRefPtr<CSSMutableStyleDeclaration> copyBlockProperties() const;
- void removeBlockProperties();
- void removeInheritableProperties();
- void removePropertiesInSet(const int* set, unsigned length);
-
- void merge(CSSMutableStyleDeclaration*, bool argOverridesOnConflict = true);
-
-private:
- String getShortHandValue(const int* properties, int number) const;
- String get4Values(const int* properties) const;
-
- DeprecatedValueList<CSSProperty> m_values;
- Node* m_node;
-};
-
-} // namespace
-
-#endif
diff --git a/WebCore/css/cssparser.cpp b/WebCore/css/cssparser.cpp
index e9380b8..7629fc9e 100644
--- a/WebCore/css/cssparser.cpp
+++ b/WebCore/css/cssparser.cpp
@@ -24,13 +24,30 @@
#include "config.h"
#include "cssparser.h"
-#include "Document.h"
-#include "css_ruleimpl.h"
-#include "csshelper.h"
+#include "CSSBorderImageValue.h"
+#include "CSSImageValue.h"
+#include "CSSImportRule.h"
+#include "CSSInheritedValue.h"
+#include "CSSInitialValue.h"
+#include "CSSMediaRule.h"
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSPrimitiveValue.h"
+#include "CSSProperty.h"
#include "CSSPropertyNames.h"
+#include "CSSRuleList.h"
+#include "CSSStyleRule.h"
#include "CSSStyleSheet.h"
+#include "CSSQuirkPrimitiveValue.h"
#include "CSSValueKeywords.h"
+#include "CSSValueList.h"
+#include "DashboardRegion.h"
+#include "Document.h"
+#include "FontFamilyValue.h"
+#include "FontValue.h"
#include "MediaList.h"
+#include "Pair.h"
+#include "ShadowValue.h"
+#include "csshelper.h"
#define YYDEBUG 0
@@ -220,7 +237,7 @@
// Now try to create a color from the rgb() or rgba() syntax.
if (parser.parseColor(dummyStyleDeclaration.get(), string)) {
- CSSValue *value = parser.parsedProperties[0]->value();
+ CSSValue* value = parser.parsedProperties[0]->value();
if (value->cssValueType() == CSSValue::CSS_PRIMITIVE_VALUE) {
CSSPrimitiveValue *primitiveValue = static_cast<CSSPrimitiveValue *>(value);
color = primitiveValue->getRGBColorValue();
@@ -2064,10 +2081,10 @@
return false;
}
-CSSValueList *CSSParser::parseFontFamily()
+CSSValueList* CSSParser::parseFontFamily()
{
- CSSValueList *list = new CSSValueList;
- Value *value = valueList->current();
+ CSSValueList* list = new CSSValueList;
+ Value* value = valueList->current();
FontFamilyValue* currFamily = 0;
while (value) {
Value* nextValue = valueList->next();
diff --git a/WebCore/css/cssstyleselector.cpp b/WebCore/css/cssstyleselector.cpp
index 888d48d..c0fade0 100644
--- a/WebCore/css/cssstyleselector.cpp
+++ b/WebCore/css/cssstyleselector.cpp
@@ -24,10 +24,21 @@
#include "config.h"
#include "cssstyleselector.h"
+#include "CSSBorderImageValue.h"
+#include "CSSImageValue.h"
+#include "CSSImportRule.h"
+#include "CSSMediaRule.h"
+#include "CSSProperty.h"
#include "CSSPropertyNames.h"
+#include "CSSRuleList.h"
+#include "CSSStyleRule.h"
#include "CSSStyleSheet.h"
#include "CSSValueKeywords.h"
+#include "CSSValueList.h"
#include "CachedImage.h"
+#include "DashboardRegion.h"
+#include "FontFamilyValue.h"
+#include "FontValue.h"
#include "Frame.h"
#include "HTMLDocument.h"
#include "HTMLElement.h"
@@ -36,10 +47,13 @@
#include "History.h"
#include "KWQKHTMLSettings.h"
#include "MediaList.h"
+#include "Pair.h"
+#include "RectImpl.h"
#include "RenderTheme.h"
#include "StyleSheetList.h"
#include "UserAgentStyleSheets.h"
#include "loader.h"
+#include "ShadowValue.h"
using namespace std;
@@ -582,7 +596,7 @@
Node* CSSStyleSelector::locateCousinList(Element* parent)
{
if (parent && parent->isStyledElement()) {
- StyledElement* p = static_cast<StyledElement *>(parent);
+ StyledElement* p = static_cast<StyledElement*>(parent);
if (p->renderer() && !p->inlineStyleDecl() && !p->hasID()) {
Node* r = p->previousSibling();
int subcount = 0;
@@ -1111,7 +1125,7 @@
n = n->parentNode();
if (!n || !n->isElementNode())
return false;
- } while (!checkOneSelector(sel, static_cast<Element *>(n)));
+ } while (!checkOneSelector(sel, static_cast<Element*>(n)));
break;
case CSSSelector::Child:
{
@@ -1121,7 +1135,7 @@
n = n->parentNode();
if (!n || !n->isElementNode())
return false;
- if (!checkOneSelector(sel, static_cast<Element *>(n)))
+ if (!checkOneSelector(sel, static_cast<Element*>(n)))
return false;
break;
}
@@ -1153,7 +1167,7 @@
(sel->pseudoType() == CSSSelector::PseudoHover ||
sel->pseudoType() == CSSSelector::PseudoActive));
- Element *elem = static_cast<Element *>(n);
+ Element *elem = static_cast<Element*>(n);
// a selector is invalid if something follows :first-xxx
if (elem == element && dynamicPseudo != RenderStyle::NOPSEUDO)
return false;
@@ -1584,20 +1598,20 @@
int len = sheet->length();
for (int i = 0; i < len; i++) {
- StyleBase *item = sheet->item(i);
+ StyleBase* item = sheet->item(i);
if (item->isStyleRule()) {
CSSStyleRule* rule = static_cast<CSSStyleRule*>(item);
for (CSSSelector* s = rule->selector(); s; s = s->next())
addRule(rule, s);
}
else if(item->isImportRule()) {
- CSSImportRule *import = static_cast<CSSImportRule *>(item);
+ CSSImportRule* import = static_cast<CSSImportRule*>(item);
if (!import->media() || import->media()->contains(medium))
addRulesFromSheet(import->styleSheet(), medium);
}
else if(item->isMediaRule()) {
- CSSMediaRule *r = static_cast<CSSMediaRule*>(item);
- CSSRuleList *rules = r->cssRules();
+ CSSMediaRule* r = static_cast<CSSMediaRule*>(item);
+ CSSRuleList* rules = r->cssRules();
if ((!r->media() || r->media()->contains(medium)) && rules) {
// Traverse child elements of the @media rule.
@@ -1681,7 +1695,7 @@
void CSSStyleSelector::applyProperty(int id, CSSValue *value)
{
CSSPrimitiveValue *primitiveValue = 0;
- if(value->isPrimitiveValue()) primitiveValue = static_cast<CSSPrimitiveValue *>(value);
+ if(value->isPrimitiveValue()) primitiveValue = static_cast<CSSPrimitiveValue*>(value);
Length l;
bool apply = false;
@@ -2243,7 +2257,7 @@
style->setCursor((ECursor)(primitiveValue->getIdent() - CSS_VAL_AUTO));
style->setCursorImage(0);
} else if (type == CSSPrimitiveValue::CSS_URI) {
- CSSImageValue *image = static_cast<CSSImageValue *>(primitiveValue);
+ CSSImageValue* image = static_cast<CSSImageValue*>(primitiveValue);
style->setCursor(CURSOR_AUTO);
style->setCursorImage(image->image(element->document()->docLoader()));
}
@@ -2309,9 +2323,9 @@
case CSS_PROP_LIST_STYLE_IMAGE:
{
HANDLE_INHERIT_AND_INITIAL(listStyleImage, ListStyleImage)
- if (!primitiveValue) return;
- style->setListStyleImage(static_cast<CSSImageValue *>(primitiveValue)
- ->image(element->document()->docLoader()));
+ if (!primitiveValue)
+ return;
+ style->setListStyleImage(static_cast<CSSImageValue*>(primitiveValue)->image(element->document()->docLoader()));
break;
}
@@ -2895,7 +2909,7 @@
} else if (!primitiveValue) {
break;
} else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RECT) {
- RectImpl *rect = primitiveValue->getRectValue();
+ RectImpl* rect = primitiveValue->getRectValue();
if (!rect)
break;
top = convertToLength(rect->top(), style);
@@ -2930,13 +2944,13 @@
}
if (!value->isValueList()) return;
- CSSValueList *list = static_cast<CSSValueList *>(value);
+ CSSValueList *list = static_cast<CSSValueList*>(value);
int len = list->length();
for (int i = 0; i < len; i++) {
CSSValue *item = list->item(i);
if (!item->isPrimitiveValue()) continue;
- CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue *>(item);
+ CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue*>(item);
if (val->primitiveType()==CSSPrimitiveValue::CSS_STRING)
style->setContent(val->getStringValue().impl(), i != 0);
else if (val->primitiveType()==CSSPrimitiveValue::CSS_ATTR) {
@@ -2945,7 +2959,7 @@
style->setContent(element->getAttribute(attr).impl(), i != 0);
}
else if (val->primitiveType()==CSSPrimitiveValue::CSS_URI) {
- CSSImageValue *image = static_cast<CSSImageValue *>(val);
+ CSSImageValue *image = static_cast<CSSImageValue*>(val);
style->setContent(image->image(element->document()->docLoader()), i != 0);
}
}
@@ -2980,7 +2994,7 @@
if (!value->isValueList()) return;
FontDescription fontDescription = style->fontDescription();
- CSSValueList *list = static_cast<CSSValueList *>(value);
+ CSSValueList *list = static_cast<CSSValueList*>(value);
int len = list->length();
FontFamily& firstFamily = fontDescription.firstFamily();
FontFamily *currFamily = 0;
@@ -2988,10 +3002,10 @@
for(int i = 0; i < len; i++) {
CSSValue *item = list->item(i);
if(!item->isPrimitiveValue()) continue;
- CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue *>(item);
+ CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue*>(item);
AtomicString face;
if(val->primitiveType() == CSSPrimitiveValue::CSS_STRING)
- face = static_cast<FontFamilyValue *>(val)->fontName();
+ face = static_cast<FontFamilyValue*>(val)->fontName();
else if (val->primitiveType() == CSSPrimitiveValue::CSS_IDENT) {
switch (val->getIdent()) {
case CSS_VAL__WEBKIT_BODY:
@@ -3052,13 +3066,13 @@
// do nothing
} else {
if(!value->isValueList()) return;
- CSSValueList *list = static_cast<CSSValueList *>(value);
+ CSSValueList *list = static_cast<CSSValueList*>(value);
int len = list->length();
for(int i = 0; i < len; i++)
{
CSSValue *item = list->item(i);
if(!item->isPrimitiveValue()) continue;
- primitiveValue = static_cast<CSSPrimitiveValue *>(item);
+ primitiveValue = static_cast<CSSPrimitiveValue*>(item);
switch(primitiveValue->getIdent())
{
case CSS_VAL_NONE:
@@ -3213,7 +3227,7 @@
if (style->setFontDescription(fontDescription))
fontDirty = true;
} else if (value->isFontValue()) {
- FontValue *font = static_cast<FontValue *>(value);
+ FontValue *font = static_cast<FontValue*>(value);
if (!font->style || !font->variant || !font->weight ||
!font->size || !font->lineHeight || !font->family)
return;
@@ -3286,7 +3300,7 @@
bool firstBinding = true;
for (unsigned int i = 0; i < list->length(); i++) {
CSSValue *item = list->item(i);
- CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue *>(item);
+ CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue*>(item);
if (val->primitiveType() == CSSPrimitiveValue::CSS_URI) {
if (firstBinding) {
firstBinding = false;
@@ -3454,10 +3468,10 @@
if (!value->isValueList())
return;
- CSSValueList *list = static_cast<CSSValueList *>(value);
+ CSSValueList *list = static_cast<CSSValueList*>(value);
int len = list->length();
for (int i = 0; i < len; i++) {
- ShadowValue *item = static_cast<ShadowValue*>(list->item(i));
+ ShadowValue* item = static_cast<ShadowValue*>(list->item(i));
int x = item->x->computeLengthInt(style);
int y = item->y->computeLengthInt(style);
int blur = item->blur ? item->blur->computeLengthInt(style) : 0;
@@ -3930,7 +3944,7 @@
if (!value->isPrimitiveValue()) return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
- layer->setBackgroundImage(static_cast<CSSImageValue *>(primitiveValue)->image(element->document()->docLoader()));
+ layer->setBackgroundImage(static_cast<CSSImageValue*>(primitiveValue)->image(element->document()->docLoader()));
}
void CSSStyleSelector::mapBackgroundRepeat(BackgroundLayer* layer, CSSValue* value)
diff --git a/WebCore/css/cssstyleselector.h b/WebCore/css/cssstyleselector.h
index 2cc37e3..bf00346 100644
--- a/WebCore/css/cssstyleselector.h
+++ b/WebCore/css/cssstyleselector.h
@@ -24,7 +24,6 @@
#ifndef CSS_cssstyleselector_h_
#define CSS_cssstyleselector_h_
-#include "css_ruleimpl.h"
#include "render_style.h"
class KHTMLSettings;
@@ -32,9 +31,11 @@
namespace WebCore {
+class CSSMutableStyleDeclaration;
class CSSProperty;
class CSSRuleData;
class CSSRuleDataList;
+class CSSRuleList;
class CSSRuleSet;
class CSSSelector;
class CSSStyleSheet;