WebCore:
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jun 2008 19:16:22 +0000 (19:16 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jun 2008 19:16:22 +0000 (19:16 +0000)
2008-06-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam.

        - more of https://bugs.webkit.org/show_bug.cgi?id=17257
          start ref counts at 1 instead of 0 for speed

        Change StyleBase and all classes derived from it.

        * bindings/js/JSRGBColor.cpp:
        (WebCore::JSRGBColor::getValueProperty):
        * bindings/objc/DOMRGBColor.mm:
        (-[DOMRGBColor red]):
        (-[DOMRGBColor green]):
        (-[DOMRGBColor blue]):
        (-[DOMRGBColor alpha]):
        * css/CSSBorderImageValue.cpp:
        (WebCore::CSSBorderImageValue::cssText):
        * css/CSSBorderImageValue.h:
        (WebCore::CSSBorderImageValue::create):
        * css/CSSCanvasValue.h:
        (WebCore::CSSCanvasValue::create):
        (WebCore::CSSCanvasValue::setName):
        (WebCore::CSSCanvasValue::CSSCanvasValue):
        * css/CSSCharsetRule.cpp:
        (WebCore::CSSCharsetRule::CSSCharsetRule):
        * css/CSSCharsetRule.h:
        (WebCore::CSSCharsetRule::create):
        (WebCore::CSSCharsetRule::encoding):
        (WebCore::CSSCharsetRule::isCharsetRule):
        (WebCore::CSSCharsetRule::type):
        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::valueForShadow):
        (WebCore::valueForNinePieceImage):
        (WebCore::valueForReflection):
        (WebCore::getPositionOffsetValue):
        (WebCore::currentColorOrValidColor):
        (WebCore::getBorderRadiusCornerValue):
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        * css/CSSComputedStyleDeclaration.h:
        (WebCore::computedStyle):
        * css/CSSCursorImageValue.h:
        (WebCore::CSSCursorImageValue::create):
        * css/CSSFontFaceRule.cpp:
        (WebCore::CSSFontFaceRule::CSSFontFaceRule):
        * css/CSSFontFaceRule.h:
        (WebCore::CSSFontFaceRule::create):
        (WebCore::CSSFontFaceRule::isFontFaceRule):
        (WebCore::CSSFontFaceRule::type):
        * css/CSSFontFaceSrcValue.h:
        (WebCore::CSSFontFaceSrcValue::create):
        (WebCore::CSSFontFaceSrcValue::createLocal):
        (WebCore::CSSFontFaceSrcValue::~CSSFontFaceSrcValue):
        (WebCore::CSSFontFaceSrcValue::CSSFontFaceSrcValue):
        * css/CSSGradientValue.h:
        (WebCore::CSSGradientColorStop::CSSGradientColorStop):
        (WebCore::CSSGradientValue::create):
        (WebCore::CSSGradientValue::CSSGradientValue):
        * css/CSSImageGeneratorValue.h:
        (WebCore::CSSImageGeneratorValue::isImageGeneratorValue):
        * css/CSSImageValue.h:
        (WebCore::CSSImageValue::create):
        * css/CSSImportRule.cpp:
        (WebCore::CSSImportRule::CSSImportRule):
        (WebCore::CSSImportRule::setCSSStyleSheet):
        * css/CSSImportRule.h:
        (WebCore::CSSImportRule::create):
        (WebCore::CSSImportRule::isImportRule):
        (WebCore::CSSImportRule::type):
        * css/CSSInheritedValue.h:
        (WebCore::CSSInheritedValue::create):
        (WebCore::CSSInheritedValue::CSSInheritedValue):
        * css/CSSInitialValue.h:
        (WebCore::CSSInitialValue::createExplicit):
        (WebCore::CSSInitialValue::createImplicit):
        (WebCore::CSSInitialValue::CSSInitialValue):
        * css/CSSMediaRule.cpp:
        (WebCore::CSSMediaRule::CSSMediaRule):
        * css/CSSMediaRule.h:
        (WebCore::CSSMediaRule::create):
        (WebCore::CSSMediaRule::isMediaRule):
        (WebCore::CSSMediaRule::type):
        * css/CSSMutableStyleDeclaration.cpp:
        (WebCore::CSSMutableStyleDeclaration::setProperty):
        (WebCore::CSSMutableStyleDeclaration::setStringProperty):
        * css/CSSMutableStyleDeclaration.h:
        (WebCore::CSSMutableStyleDeclaration::create):
        * css/CSSPageRule.cpp:
        (WebCore::CSSPageRule::CSSPageRule):
        * css/CSSPageRule.h:
        (WebCore::CSSPageRule::create):
        * css/CSSParser.cpp:
        (WebCore::CSSParser::parseColor):
        (WebCore::CSSParser::parseValue):
        (WebCore::CSSParser::addFillValue):
        (WebCore::CSSParser::parseFillShorthand):
        (WebCore::CSSParser::addTransitionValue):
        (WebCore::CSSParser::parseTransitionShorthand):
        (WebCore::CSSParser::parseShorthand):
        (WebCore::CSSParser::parseContent):
        (WebCore::CSSParser::parseBackgroundColor):
        (WebCore::CSSParser::parseFillPositionXY):
        (WebCore::CSSParser::parseFillPosition):
        (WebCore::CSSParser::parseFillSize):
        (WebCore::CSSParser::parseFillProperty):
        (WebCore::CSSParser::parseTransitionDuration):
        (WebCore::CSSParser::parseTransitionRepeatCount):
        (WebCore::CSSParser::parseTransitionTimingFunction):
        (WebCore::CSSParser::parseTransitionProperty):
        (WebCore::CSSParser::parseDashboardRegions):
        (WebCore::CSSParser::parseCounterContent):
        (WebCore::CSSParser::parseShape):
        (WebCore::CSSParser::parseFont):
        (WebCore::CSSParser::parseFontFamily):
        (WebCore::CSSParser::parseFontFaceSrc):
        (WebCore::CSSParser::parseFontFaceUnicodeRange):
        (WebCore::ShadowParseContext::commitValue):
        (WebCore::ShadowParseContext::commitLength):
        (WebCore::CSSParser::parseShadow):
        (WebCore::CSSParser::parseReflect):
        (WebCore::BorderImageParseContext::commitNumber):
        (WebCore::BorderImageParseContext::commitBorderImage):
        (WebCore::CSSParser::parseBorderImage):
        (WebCore::CSSParser::parseCounter):
        (WebCore::parseGradientPoint):
        (WebCore::parseGradientColorStop):
        (WebCore::CSSParser::parseGradient):
        (WebCore::CSSParser::parseCanvas):
        (WebCore::CSSParser::parseTransform):
        (WebCore::CSSParser::createMediaList):
        (WebCore::CSSParser::createCharsetRule):
        (WebCore::CSSParser::createImportRule):
        (WebCore::CSSParser::createMediaRule):
        (WebCore::CSSParser::createStyleRule):
        (WebCore::CSSParser::createFontFaceRule):
        * css/CSSPrimitiveValue.h:
        (WebCore::CSSPrimitiveValue::):
        (WebCore::CSSPrimitiveValue::createIdentifier):
        (WebCore::CSSPrimitiveValue::createColor):
        (WebCore::CSSPrimitiveValue::create):
        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
        (WebCore::CSSPrimitiveValue::isPrimitiveValue):
        * css/CSSQuirkPrimitiveValue.h:
        (WebCore::CSSQuirkPrimitiveValue::create):
        * css/CSSReflectValue.h:
        (WebCore::CSSReflectValue::create):
        * css/CSSRule.cpp:
        (WebCore::CSSRule::parentRule):
        (WebCore::CSSRule::setCssText):
        * css/CSSRule.h:
        (WebCore::CSSRule::CSSRule):
        (WebCore::CSSRule::isRule):
        * css/CSSStyleDeclaration.cpp:
        (WebCore::CSSStyleDeclaration::copyPropertiesInSet):
        * css/CSSStyleDeclaration.h:
        * css/CSSStyleRule.cpp:
        (WebCore::CSSStyleRule::CSSStyleRule):
        * css/CSSStyleRule.h:
        (WebCore::CSSStyleRule::create):
        (WebCore::CSSStyleRule::isStyleRule):
        (WebCore::CSSStyleRule::type):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::CSSStyleSelector):
        (WebCore::parseUASheet):
        (WebCore::CSSRuleSet::addRulesFromSheet):
        (WebCore::CSSStyleSelector::applyProperty):
        * css/CSSStyleSheet.cpp:
        (WebCore::CSSStyleSheet::checkLoaded):
        * css/CSSStyleSheet.h:
        (WebCore::CSSStyleSheet::create):
        (WebCore::CSSStyleSheet::isCSSStyleSheet):
        (WebCore::CSSStyleSheet::type):
        * css/CSSTimingFunctionValue.h:
        (WebCore::CSSTimingFunctionValue::create):
        (WebCore::CSSTimingFunctionValue::CSSTimingFunctionValue):
        (WebCore::CSSTimingFunctionValue::isTransitionTimingFunctionValue):
        * css/CSSTransformValue.cpp:
        (WebCore::CSSTransformValue::CSSTransformValue):
        (WebCore::CSSTransformValue::~CSSTransformValue):
        (WebCore::CSSTransformValue::addValue):
        (WebCore::CSSTransformValue::cssText):
        * css/CSSTransformValue.h:
        (WebCore::CSSTransformValue::create):
        * css/CSSUnicodeRangeValue.h:
        (WebCore::CSSUnicodeRangeValue::create):
        (WebCore::CSSUnicodeRangeValue::CSSUnicodeRangeValue):
        * css/CSSUnknownRule.h:
        * css/CSSValue.h:
        (WebCore::CSSValue::isImageGeneratorValue):
        (WebCore::CSSValue::isImageValue):
        (WebCore::CSSValue::isPrimitiveValue):
        (WebCore::CSSValue::isValueList):
        (WebCore::CSSValue::isSVGColor):
        (WebCore::CSSValue::isSVGPaint):
        (WebCore::CSSValue::CSSValue):
        * css/CSSValueList.h:
        (WebCore::CSSValueList::createCommaSeparated):
        (WebCore::CSSValueList::createSpaceSeparated):
        (WebCore::CSSValueList::isValueList):
        * css/FontFamilyValue.h:
        (WebCore::FontFamilyValue::create):
        * css/FontValue.h:
        (WebCore::FontValue::create):
        (WebCore::FontValue::FontValue):
        (WebCore::FontValue::isFontValue):
        * css/MediaList.cpp:
        (WebCore::MediaList::MediaList):
        (WebCore::MediaList::deleteMedium):
        (WebCore::MediaList::setMediaText):
        * css/MediaList.h:
        (WebCore::MediaList::create):
        (WebCore::MediaList::createAllowingDescriptionSyntax):
        (WebCore::MediaList::length):
        (WebCore::MediaList::mediaQueries):
        * css/MediaQueryEvaluator.cpp:
        (WebCore::MediaQueryEvaluator::eval):
        * css/MediaQueryExp.cpp:
        (WebCore::MediaQueryExp::MediaQueryExp):
        * css/SVGCSSComputedStyleDeclaration.cpp:
        (WebCore::glyphOrientationToCSSPrimitiveValue):
        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
        * css/SVGCSSParser.cpp:
        (WebCore::CSSParser::parseSVGValue):
        (WebCore::CSSParser::parseSVGStrokeDasharray):
        (WebCore::CSSParser::parseSVGPaint):
        (WebCore::CSSParser::parseSVGColor):
        * css/ShadowValue.h:
        (WebCore::ShadowValue::create):
        * css/StyleBase.h:
        (WebCore::StyleBase::isCSSStyleSheet):
        (WebCore::StyleBase::isFontFaceRule):
        (WebCore::StyleBase::isRule):
        (WebCore::StyleBase::isStyleRule):
        (WebCore::StyleBase::isStyleSheet):
        (WebCore::StyleBase::isXSLStyleSheet):
        (WebCore::StyleBase::StyleBase):
        * css/StyleList.cpp:
        * css/StyleList.h:
        (WebCore::StyleList::StyleList):
        * css/StyleSheet.h:
        (WebCore::StyleSheet::styleSheetChanged):
        (WebCore::StyleSheet::isStyleSheet):
        * dom/CSSMappedAttributeDeclaration.h:
        (WebCore::CSSMappedAttributeDeclaration::create):
        (WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):
        * dom/DOMImplementation.cpp:
        (WebCore::DOMImplementation::createCSSStyleSheet):
        * dom/Document.cpp:
        (WebCore::Document::createCSSStyleDeclaration):
        (WebCore::Document::setCSSStyleSheet):
        (WebCore::Document::elementSheet):
        (WebCore::Document::mappedElementSheet):
        (WebCore::Document::recalcStyleSelector):
        * dom/Node.cpp:
        (WebCore::Node::querySelector):
        (WebCore::Node::querySelectorAll):
        * dom/Position.cpp:
        (WebCore::Position::computedStyle):
        * dom/ProcessingInstruction.cpp:
        (WebCore::ProcessingInstruction::checkStyleSheet):
        (WebCore::ProcessingInstruction::setCSSStyleSheet):
        (WebCore::ProcessingInstruction::setXSLStyleSheet):
        * dom/ProcessingInstruction.h:
        * dom/StyleElement.cpp:
        (WebCore::StyleElement::createSheet):
        * dom/StyledElement.cpp:
        (WebCore::StyledElement::createInlineStyleDecl):
        (WebCore::StyledElement::createMappedDecl):
        * editing/ApplyStyleCommand.cpp:
        (WebCore::ApplyStyleCommand::ApplyStyleCommand):
        (WebCore::hasTextDecorationProperty):
        (WebCore::ApplyStyleCommand::extractAndNegateTextDecorationStyle):
        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::breakOutOfEmptyListItem):
        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
        * editing/Editor.cpp:
        (WebCore::Editor::selectionHasStyle):
        (WebCore::Editor::setBaseWritingDirection):
        * editing/EditorCommand.cpp:
        (WebCore::executeApplyStyle):
        (WebCore::executeToggleStyle):
        (WebCore::executeApplyParagraphStyle):
        (WebCore::stateStyle):
        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::applyStyleAfterInsertion):
        * editing/RemoveFormatCommand.cpp:
        (WebCore::RemoveFormatCommand::doApply):
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplacementFragment::insertFragmentForTestRendering):
        * editing/markup.cpp:
        (WebCore::styleFromMatchedRulesForElement):
        (WebCore::appendStartMarkup):
        * html/HTMLBodyElement.cpp:
        (WebCore::HTMLBodyElement::createLinkDecl):
        * html/HTMLLinkElement.cpp:
        (WebCore::HTMLLinkElement::process):
        (WebCore::HTMLLinkElement::setCSSStyleSheet):
        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::pickMedia):
        * html/HTMLTableElement.cpp:
        (WebCore::HTMLTableElement::additionalAttributeStyleDecls):
        (WebCore::HTMLTableElement::addSharedCellBordersDecl):
        (WebCore::HTMLTableElement::addSharedCellPaddingDecl):
        (WebCore::HTMLTableElement::addSharedGroupDecls):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::getComputedStyle):
        * page/Frame.cpp:
        (WebCore::Frame::computeAndSetTypingStyle):
        (WebCore::Frame::selectionComputedStyle):
        * page/Frame.h:
        * rendering/style/RenderStyle.cpp:
        (WebCore::StyleCachedImage::cssValue):
        * rendering/style/RenderStyle.h:
        * svg/SVGColor.h:
        (WebCore::SVGColor::create):
        (WebCore::SVGColor::isSVGColor):
        * svg/SVGFontFaceElement.cpp:
        (WebCore::SVGFontFaceElement::SVGFontFaceElement):
        (WebCore::SVGFontFaceElement::rebuildFontFace):
        * svg/SVGFontFaceNameElement.cpp:
        (WebCore::SVGFontFaceNameElement::srcValue):
        * svg/SVGFontFaceSrcElement.cpp:
        (WebCore::SVGFontFaceSrcElement::srcValue):
        * svg/SVGFontFaceUriElement.cpp:
        (WebCore::SVGFontFaceUriElement::srcValue):
        * svg/SVGPaint.cpp:
        (WebCore::SVGPaint::SVGPaint):
        * svg/SVGPaint.h:
        (WebCore::SVGPaint::create):
        (WebCore::SVGPaint::isSVGPaint):
        * svg/animation/SMILTimeContainer.cpp:
        (WebCore::SMILTimeContainer::baseValueFor):
        * xml/XSLImportRule.cpp:
        (WebCore::XSLImportRule::XSLImportRule):
        (WebCore::XSLImportRule::setXSLStyleSheet):
        * xml/XSLImportRule.h:
        (WebCore::XSLImportRule::create):
        (WebCore::XSLImportRule::href):
        (WebCore::XSLImportRule::isImportRule):
        * xml/XSLStyleSheet.cpp:
        (WebCore::XSLStyleSheet::checkLoaded):
        (WebCore::XSLStyleSheet::loadChildSheet):
        * xml/XSLStyleSheet.h:
        (WebCore::XSLStyleSheet::create):
        (WebCore::XSLStyleSheet::createEmbedded):
        * xml/XSLTProcessor.cpp:
        (WebCore::xsltStylesheetPointer):

WebKit/mac:

2008-06-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam.

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]): Use create instead of new
        to create a CSSMutableStyleDeclaration.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34627 268f45cc-cd09-0410-ab3c-d52691b4dbfc

103 files changed:
WebCore/ChangeLog
WebCore/bindings/js/JSRGBColor.cpp
WebCore/bindings/objc/DOMRGBColor.mm
WebCore/css/CSSBorderImageValue.cpp
WebCore/css/CSSBorderImageValue.h
WebCore/css/CSSCanvasValue.h
WebCore/css/CSSCharsetRule.cpp
WebCore/css/CSSCharsetRule.h
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSComputedStyleDeclaration.h
WebCore/css/CSSCursorImageValue.h
WebCore/css/CSSFontFaceRule.cpp
WebCore/css/CSSFontFaceRule.h
WebCore/css/CSSFontFaceSrcValue.h
WebCore/css/CSSGradientValue.h
WebCore/css/CSSImageGeneratorValue.h
WebCore/css/CSSImageValue.h
WebCore/css/CSSImportRule.cpp
WebCore/css/CSSImportRule.h
WebCore/css/CSSInheritedValue.h
WebCore/css/CSSInitialValue.h
WebCore/css/CSSMediaRule.cpp
WebCore/css/CSSMediaRule.h
WebCore/css/CSSMutableStyleDeclaration.cpp
WebCore/css/CSSMutableStyleDeclaration.h
WebCore/css/CSSPageRule.cpp
WebCore/css/CSSPageRule.h
WebCore/css/CSSParser.cpp
WebCore/css/CSSPrimitiveValue.h
WebCore/css/CSSQuirkPrimitiveValue.h
WebCore/css/CSSReflectValue.h
WebCore/css/CSSRule.cpp
WebCore/css/CSSRule.h
WebCore/css/CSSStyleDeclaration.cpp
WebCore/css/CSSStyleDeclaration.h
WebCore/css/CSSStyleRule.cpp
WebCore/css/CSSStyleRule.h
WebCore/css/CSSStyleSelector.cpp
WebCore/css/CSSStyleSheet.cpp
WebCore/css/CSSStyleSheet.h
WebCore/css/CSSTimingFunctionValue.h
WebCore/css/CSSTransformValue.cpp
WebCore/css/CSSTransformValue.h
WebCore/css/CSSUnicodeRangeValue.h
WebCore/css/CSSUnknownRule.h
WebCore/css/CSSValue.h
WebCore/css/CSSValueList.h
WebCore/css/FontFamilyValue.h
WebCore/css/FontValue.h
WebCore/css/MediaList.cpp
WebCore/css/MediaList.h
WebCore/css/MediaQueryEvaluator.cpp
WebCore/css/MediaQueryExp.cpp
WebCore/css/SVGCSSComputedStyleDeclaration.cpp
WebCore/css/SVGCSSParser.cpp
WebCore/css/ShadowValue.h
WebCore/css/StyleBase.h
WebCore/css/StyleList.cpp
WebCore/css/StyleList.h
WebCore/css/StyleSheet.h
WebCore/dom/CSSMappedAttributeDeclaration.h
WebCore/dom/DOMImplementation.cpp
WebCore/dom/Document.cpp
WebCore/dom/Node.cpp
WebCore/dom/Position.cpp
WebCore/dom/ProcessingInstruction.cpp
WebCore/dom/ProcessingInstruction.h
WebCore/dom/StyleElement.cpp
WebCore/dom/StyledElement.cpp
WebCore/editing/ApplyStyleCommand.cpp
WebCore/editing/CompositeEditCommand.cpp
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/Editor.cpp
WebCore/editing/EditorCommand.cpp
WebCore/editing/InsertParagraphSeparatorCommand.cpp
WebCore/editing/RemoveFormatCommand.cpp
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/markup.cpp
WebCore/html/HTMLBodyElement.cpp
WebCore/html/HTMLLinkElement.cpp
WebCore/html/HTMLMediaElement.cpp
WebCore/html/HTMLTableElement.cpp
WebCore/page/DOMWindow.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/rendering/style/RenderStyle.cpp
WebCore/rendering/style/RenderStyle.h
WebCore/svg/SVGColor.cpp
WebCore/svg/SVGColor.h
WebCore/svg/SVGFontFaceElement.cpp
WebCore/svg/SVGFontFaceNameElement.cpp
WebCore/svg/SVGFontFaceSrcElement.cpp
WebCore/svg/SVGFontFaceUriElement.cpp
WebCore/svg/SVGPaint.cpp
WebCore/svg/SVGPaint.h
WebCore/svg/animation/SMILTimeContainer.cpp
WebCore/xml/XSLImportRule.cpp
WebCore/xml/XSLImportRule.h
WebCore/xml/XSLStyleSheet.cpp
WebCore/xml/XSLStyleSheet.h
WebCore/xml/XSLTProcessor.cpp
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebHTMLView.mm

index 862fcde7cd425ad0af272699aec06c10c6b37482..f43123a3683e852bff4f670a3ae5e706cb43a56b 100644 (file)
@@ -1,3 +1,352 @@
+2008-06-17  Darin Adler  <darin@apple.com>
+
+        Reviewed by Sam.
+
+        - more of https://bugs.webkit.org/show_bug.cgi?id=17257
+          start ref counts at 1 instead of 0 for speed
+
+        Change StyleBase and all classes derived from it.
+
+        * bindings/js/JSRGBColor.cpp:
+        (WebCore::JSRGBColor::getValueProperty):
+        * bindings/objc/DOMRGBColor.mm:
+        (-[DOMRGBColor red]):
+        (-[DOMRGBColor green]):
+        (-[DOMRGBColor blue]):
+        (-[DOMRGBColor alpha]):
+        * css/CSSBorderImageValue.cpp:
+        (WebCore::CSSBorderImageValue::cssText):
+        * css/CSSBorderImageValue.h:
+        (WebCore::CSSBorderImageValue::create):
+        * css/CSSCanvasValue.h:
+        (WebCore::CSSCanvasValue::create):
+        (WebCore::CSSCanvasValue::setName):
+        (WebCore::CSSCanvasValue::CSSCanvasValue):
+        * css/CSSCharsetRule.cpp:
+        (WebCore::CSSCharsetRule::CSSCharsetRule):
+        * css/CSSCharsetRule.h:
+        (WebCore::CSSCharsetRule::create):
+        (WebCore::CSSCharsetRule::encoding):
+        (WebCore::CSSCharsetRule::isCharsetRule):
+        (WebCore::CSSCharsetRule::type):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForShadow):
+        (WebCore::valueForNinePieceImage):
+        (WebCore::valueForReflection):
+        (WebCore::getPositionOffsetValue):
+        (WebCore::currentColorOrValidColor):
+        (WebCore::getBorderRadiusCornerValue):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSComputedStyleDeclaration.h:
+        (WebCore::computedStyle):
+        * css/CSSCursorImageValue.h:
+        (WebCore::CSSCursorImageValue::create):
+        * css/CSSFontFaceRule.cpp:
+        (WebCore::CSSFontFaceRule::CSSFontFaceRule):
+        * css/CSSFontFaceRule.h:
+        (WebCore::CSSFontFaceRule::create):
+        (WebCore::CSSFontFaceRule::isFontFaceRule):
+        (WebCore::CSSFontFaceRule::type):
+        * css/CSSFontFaceSrcValue.h:
+        (WebCore::CSSFontFaceSrcValue::create):
+        (WebCore::CSSFontFaceSrcValue::createLocal):
+        (WebCore::CSSFontFaceSrcValue::~CSSFontFaceSrcValue):
+        (WebCore::CSSFontFaceSrcValue::CSSFontFaceSrcValue):
+        * css/CSSGradientValue.h:
+        (WebCore::CSSGradientColorStop::CSSGradientColorStop):
+        (WebCore::CSSGradientValue::create):
+        (WebCore::CSSGradientValue::CSSGradientValue):
+        * css/CSSImageGeneratorValue.h:
+        (WebCore::CSSImageGeneratorValue::isImageGeneratorValue):
+        * css/CSSImageValue.h:
+        (WebCore::CSSImageValue::create):
+        * css/CSSImportRule.cpp:
+        (WebCore::CSSImportRule::CSSImportRule):
+        (WebCore::CSSImportRule::setCSSStyleSheet):
+        * css/CSSImportRule.h:
+        (WebCore::CSSImportRule::create):
+        (WebCore::CSSImportRule::isImportRule):
+        (WebCore::CSSImportRule::type):
+        * css/CSSInheritedValue.h:
+        (WebCore::CSSInheritedValue::create):
+        (WebCore::CSSInheritedValue::CSSInheritedValue):
+        * css/CSSInitialValue.h:
+        (WebCore::CSSInitialValue::createExplicit):
+        (WebCore::CSSInitialValue::createImplicit):
+        (WebCore::CSSInitialValue::CSSInitialValue):
+        * css/CSSMediaRule.cpp:
+        (WebCore::CSSMediaRule::CSSMediaRule):
+        * css/CSSMediaRule.h:
+        (WebCore::CSSMediaRule::create):
+        (WebCore::CSSMediaRule::isMediaRule):
+        (WebCore::CSSMediaRule::type):
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::setProperty):
+        (WebCore::CSSMutableStyleDeclaration::setStringProperty):
+        * css/CSSMutableStyleDeclaration.h:
+        (WebCore::CSSMutableStyleDeclaration::create):
+        * css/CSSPageRule.cpp:
+        (WebCore::CSSPageRule::CSSPageRule):
+        * css/CSSPageRule.h:
+        (WebCore::CSSPageRule::create):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseColor):
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::addFillValue):
+        (WebCore::CSSParser::parseFillShorthand):
+        (WebCore::CSSParser::addTransitionValue):
+        (WebCore::CSSParser::parseTransitionShorthand):
+        (WebCore::CSSParser::parseShorthand):
+        (WebCore::CSSParser::parseContent):
+        (WebCore::CSSParser::parseBackgroundColor):
+        (WebCore::CSSParser::parseFillPositionXY):
+        (WebCore::CSSParser::parseFillPosition):
+        (WebCore::CSSParser::parseFillSize):
+        (WebCore::CSSParser::parseFillProperty):
+        (WebCore::CSSParser::parseTransitionDuration):
+        (WebCore::CSSParser::parseTransitionRepeatCount):
+        (WebCore::CSSParser::parseTransitionTimingFunction):
+        (WebCore::CSSParser::parseTransitionProperty):
+        (WebCore::CSSParser::parseDashboardRegions):
+        (WebCore::CSSParser::parseCounterContent):
+        (WebCore::CSSParser::parseShape):
+        (WebCore::CSSParser::parseFont):
+        (WebCore::CSSParser::parseFontFamily):
+        (WebCore::CSSParser::parseFontFaceSrc):
+        (WebCore::CSSParser::parseFontFaceUnicodeRange):
+        (WebCore::ShadowParseContext::commitValue):
+        (WebCore::ShadowParseContext::commitLength):
+        (WebCore::CSSParser::parseShadow):
+        (WebCore::CSSParser::parseReflect):
+        (WebCore::BorderImageParseContext::commitNumber):
+        (WebCore::BorderImageParseContext::commitBorderImage):
+        (WebCore::CSSParser::parseBorderImage):
+        (WebCore::CSSParser::parseCounter):
+        (WebCore::parseGradientPoint):
+        (WebCore::parseGradientColorStop):
+        (WebCore::CSSParser::parseGradient):
+        (WebCore::CSSParser::parseCanvas):
+        (WebCore::CSSParser::parseTransform):
+        (WebCore::CSSParser::createMediaList):
+        (WebCore::CSSParser::createCharsetRule):
+        (WebCore::CSSParser::createImportRule):
+        (WebCore::CSSParser::createMediaRule):
+        (WebCore::CSSParser::createStyleRule):
+        (WebCore::CSSParser::createFontFaceRule):
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::):
+        (WebCore::CSSPrimitiveValue::createIdentifier):
+        (WebCore::CSSPrimitiveValue::createColor):
+        (WebCore::CSSPrimitiveValue::create):
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::isPrimitiveValue):
+        * css/CSSQuirkPrimitiveValue.h:
+        (WebCore::CSSQuirkPrimitiveValue::create):
+        * css/CSSReflectValue.h:
+        (WebCore::CSSReflectValue::create):
+        * css/CSSRule.cpp:
+        (WebCore::CSSRule::parentRule):
+        (WebCore::CSSRule::setCssText):
+        * css/CSSRule.h:
+        (WebCore::CSSRule::CSSRule):
+        (WebCore::CSSRule::isRule):
+        * css/CSSStyleDeclaration.cpp:
+        (WebCore::CSSStyleDeclaration::copyPropertiesInSet):
+        * css/CSSStyleDeclaration.h:
+        * css/CSSStyleRule.cpp:
+        (WebCore::CSSStyleRule::CSSStyleRule):
+        * css/CSSStyleRule.h:
+        (WebCore::CSSStyleRule::create):
+        (WebCore::CSSStyleRule::isStyleRule):
+        (WebCore::CSSStyleRule::type):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::CSSStyleSelector):
+        (WebCore::parseUASheet):
+        (WebCore::CSSRuleSet::addRulesFromSheet):
+        (WebCore::CSSStyleSelector::applyProperty):
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::checkLoaded):
+        * css/CSSStyleSheet.h:
+        (WebCore::CSSStyleSheet::create):
+        (WebCore::CSSStyleSheet::isCSSStyleSheet):
+        (WebCore::CSSStyleSheet::type):
+        * css/CSSTimingFunctionValue.h:
+        (WebCore::CSSTimingFunctionValue::create):
+        (WebCore::CSSTimingFunctionValue::CSSTimingFunctionValue):
+        (WebCore::CSSTimingFunctionValue::isTransitionTimingFunctionValue):
+        * css/CSSTransformValue.cpp:
+        (WebCore::CSSTransformValue::CSSTransformValue):
+        (WebCore::CSSTransformValue::~CSSTransformValue):
+        (WebCore::CSSTransformValue::addValue):
+        (WebCore::CSSTransformValue::cssText):
+        * css/CSSTransformValue.h:
+        (WebCore::CSSTransformValue::create):
+        * css/CSSUnicodeRangeValue.h:
+        (WebCore::CSSUnicodeRangeValue::create):
+        (WebCore::CSSUnicodeRangeValue::CSSUnicodeRangeValue):
+        * css/CSSUnknownRule.h:
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isImageGeneratorValue):
+        (WebCore::CSSValue::isImageValue):
+        (WebCore::CSSValue::isPrimitiveValue):
+        (WebCore::CSSValue::isValueList):
+        (WebCore::CSSValue::isSVGColor):
+        (WebCore::CSSValue::isSVGPaint):
+        (WebCore::CSSValue::CSSValue):
+        * css/CSSValueList.h:
+        (WebCore::CSSValueList::createCommaSeparated):
+        (WebCore::CSSValueList::createSpaceSeparated):
+        (WebCore::CSSValueList::isValueList):
+        * css/FontFamilyValue.h:
+        (WebCore::FontFamilyValue::create):
+        * css/FontValue.h:
+        (WebCore::FontValue::create):
+        (WebCore::FontValue::FontValue):
+        (WebCore::FontValue::isFontValue):
+        * css/MediaList.cpp:
+        (WebCore::MediaList::MediaList):
+        (WebCore::MediaList::deleteMedium):
+        (WebCore::MediaList::setMediaText):
+        * css/MediaList.h:
+        (WebCore::MediaList::create):
+        (WebCore::MediaList::createAllowingDescriptionSyntax):
+        (WebCore::MediaList::length):
+        (WebCore::MediaList::mediaQueries):
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::MediaQueryEvaluator::eval):
+        * css/MediaQueryExp.cpp:
+        (WebCore::MediaQueryExp::MediaQueryExp):
+        * css/SVGCSSComputedStyleDeclaration.cpp:
+        (WebCore::glyphOrientationToCSSPrimitiveValue):
+        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
+        * css/SVGCSSParser.cpp:
+        (WebCore::CSSParser::parseSVGValue):
+        (WebCore::CSSParser::parseSVGStrokeDasharray):
+        (WebCore::CSSParser::parseSVGPaint):
+        (WebCore::CSSParser::parseSVGColor):
+        * css/ShadowValue.h:
+        (WebCore::ShadowValue::create):
+        * css/StyleBase.h:
+        (WebCore::StyleBase::isCSSStyleSheet):
+        (WebCore::StyleBase::isFontFaceRule):
+        (WebCore::StyleBase::isRule):
+        (WebCore::StyleBase::isStyleRule):
+        (WebCore::StyleBase::isStyleSheet):
+        (WebCore::StyleBase::isXSLStyleSheet):
+        (WebCore::StyleBase::StyleBase):
+        * css/StyleList.cpp:
+        * css/StyleList.h:
+        (WebCore::StyleList::StyleList):
+        * css/StyleSheet.h:
+        (WebCore::StyleSheet::styleSheetChanged):
+        (WebCore::StyleSheet::isStyleSheet):
+        * dom/CSSMappedAttributeDeclaration.h:
+        (WebCore::CSSMappedAttributeDeclaration::create):
+        (WebCore::CSSMappedAttributeDeclaration::CSSMappedAttributeDeclaration):
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createCSSStyleSheet):
+        * dom/Document.cpp:
+        (WebCore::Document::createCSSStyleDeclaration):
+        (WebCore::Document::setCSSStyleSheet):
+        (WebCore::Document::elementSheet):
+        (WebCore::Document::mappedElementSheet):
+        (WebCore::Document::recalcStyleSelector):
+        * dom/Node.cpp:
+        (WebCore::Node::querySelector):
+        (WebCore::Node::querySelectorAll):
+        * dom/Position.cpp:
+        (WebCore::Position::computedStyle):
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::checkStyleSheet):
+        (WebCore::ProcessingInstruction::setCSSStyleSheet):
+        (WebCore::ProcessingInstruction::setXSLStyleSheet):
+        * dom/ProcessingInstruction.h:
+        * dom/StyleElement.cpp:
+        (WebCore::StyleElement::createSheet):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::createInlineStyleDecl):
+        (WebCore::StyledElement::createMappedDecl):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::ApplyStyleCommand):
+        (WebCore::hasTextDecorationProperty):
+        (WebCore::ApplyStyleCommand::extractAndNegateTextDecorationStyle):
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::breakOutOfEmptyListItem):
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
+        * editing/Editor.cpp:
+        (WebCore::Editor::selectionHasStyle):
+        (WebCore::Editor::setBaseWritingDirection):
+        * editing/EditorCommand.cpp:
+        (WebCore::executeApplyStyle):
+        (WebCore::executeToggleStyle):
+        (WebCore::executeApplyParagraphStyle):
+        (WebCore::stateStyle):
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::applyStyleAfterInsertion):
+        * editing/RemoveFormatCommand.cpp:
+        (WebCore::RemoveFormatCommand::doApply):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::insertFragmentForTestRendering):
+        * editing/markup.cpp:
+        (WebCore::styleFromMatchedRulesForElement):
+        (WebCore::appendStartMarkup):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::createLinkDecl):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+        (WebCore::HTMLLinkElement::setCSSStyleSheet):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::pickMedia):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::additionalAttributeStyleDecls):
+        (WebCore::HTMLTableElement::addSharedCellBordersDecl):
+        (WebCore::HTMLTableElement::addSharedCellPaddingDecl):
+        (WebCore::HTMLTableElement::addSharedGroupDecls):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::getComputedStyle):
+        * page/Frame.cpp:
+        (WebCore::Frame::computeAndSetTypingStyle):
+        (WebCore::Frame::selectionComputedStyle):
+        * page/Frame.h:
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::StyleCachedImage::cssValue):
+        * rendering/style/RenderStyle.h:
+        * svg/SVGColor.h:
+        (WebCore::SVGColor::create):
+        (WebCore::SVGColor::isSVGColor):
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::SVGFontFaceElement):
+        (WebCore::SVGFontFaceElement::rebuildFontFace):
+        * svg/SVGFontFaceNameElement.cpp:
+        (WebCore::SVGFontFaceNameElement::srcValue):
+        * svg/SVGFontFaceSrcElement.cpp:
+        (WebCore::SVGFontFaceSrcElement::srcValue):
+        * svg/SVGFontFaceUriElement.cpp:
+        (WebCore::SVGFontFaceUriElement::srcValue):
+        * svg/SVGPaint.cpp:
+        (WebCore::SVGPaint::SVGPaint):
+        * svg/SVGPaint.h:
+        (WebCore::SVGPaint::create):
+        (WebCore::SVGPaint::isSVGPaint):
+        * svg/animation/SMILTimeContainer.cpp:
+        (WebCore::SMILTimeContainer::baseValueFor):
+        * xml/XSLImportRule.cpp:
+        (WebCore::XSLImportRule::XSLImportRule):
+        (WebCore::XSLImportRule::setXSLStyleSheet):
+        * xml/XSLImportRule.h:
+        (WebCore::XSLImportRule::create):
+        (WebCore::XSLImportRule::href):
+        (WebCore::XSLImportRule::isImportRule):
+        * xml/XSLStyleSheet.cpp:
+        (WebCore::XSLStyleSheet::checkLoaded):
+        (WebCore::XSLStyleSheet::loadChildSheet):
+        * xml/XSLStyleSheet.h:
+        (WebCore::XSLStyleSheet::create):
+        (WebCore::XSLStyleSheet::createEmbedded):
+        * xml/XSLTProcessor.cpp:
+        (WebCore::xsltStylesheetPointer):
+
 2008-06-17  Michelangelo De Simone  <m.des@mac.com>
 
         Reviewed by Adele.
index 44f00a9ef905cc4b20a6e2e73e895b7048385d93..9a339665cae0721b61454ff332a494e711f7c726 100644 (file)
@@ -68,7 +68,7 @@ JSValue* JSRGBColor::getValueProperty(ExecState* exec, int token) const
             color >>= 8;
             // fall through
         case Blue:
-            return toJS(exec, new CSSPrimitiveValue(color & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
+            return toJS(exec, CSSPrimitiveValue::create(color & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
         default:
             return 0;
     }
index 8c35a9fca099046dd3be360a57c13e786be60026..0bf9de7e841c2a54db0b67f6f313b68b92b0542c 100644 (file)
@@ -91,28 +91,28 @@ void removeWrapperForRGB(WebCore::RGBA32 value)
 {
     WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal);
     int value = (rgb >> 16) & 0xFF;
-    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:new WebCore::CSSPrimitiveValue(value, WebCore::CSSPrimitiveValue::CSS_NUMBER)];
+    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()];
 }
 
 - (DOMCSSPrimitiveValue *)green
 {
     WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal);
     int value = (rgb >> 8) & 0xFF;
-    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:new WebCore::CSSPrimitiveValue(value, WebCore::CSSPrimitiveValue::CSS_NUMBER)];
+    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()];
 }
 
 - (DOMCSSPrimitiveValue *)blue
 {
     WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal);
     int value = rgb & 0xFF;
-    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:new WebCore::CSSPrimitiveValue(value, WebCore::CSSPrimitiveValue::CSS_NUMBER)];
+    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()];
 }
 
 - (DOMCSSPrimitiveValue *)alpha
 {
     WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal);
     float value = static_cast<float>(WebCore::Color(rgb).alpha()) / 0xFF;
-    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:new WebCore::CSSPrimitiveValue(value, WebCore::CSSPrimitiveValue::CSS_NUMBER)];
+    return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()];
     
 }
 
index 25361fbe07d284ed36fe4d00cc5b3029ab0422dd..c639e4c61b6763e027eaa610791ba8438d149a4f 100644 (file)
@@ -1,8 +1,6 @@
-/**
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -53,9 +51,9 @@ String CSSBorderImageValue::cssText() const
 
     // Now the keywords.
     text += " ";
-    text += CSSPrimitiveValue(m_horizontalSizeRule).cssText();
+    text += CSSPrimitiveValue::createIdentifier(m_horizontalSizeRule)->cssText();
     text += " ";
-    text += CSSPrimitiveValue(m_verticalSizeRule).cssText();
+    text += CSSPrimitiveValue::createIdentifier(m_verticalSizeRule)->cssText();
 
     return text;
 }
index 6c59bd27b1b86fd6883873501b6076fb5fd23153..b61a19e8cbde067c9576e777283ce598a93d8e02 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -24,7 +22,6 @@
 #define CSSBorderImageValue_h
 
 #include "CSSValue.h"
-
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
@@ -34,14 +31,15 @@ class Rect;
 
 class CSSBorderImageValue : public CSSValue {
 public:
-    CSSBorderImageValue();
-    CSSBorderImageValue(PassRefPtr<CSSValue>, PassRefPtr<Rect>, int horizontalRule, int verticalRule);
+    static PassRefPtr<CSSBorderImageValue> create(PassRefPtr<CSSValue> image, PassRefPtr<Rect> sliceRect, int horizontalRule, int verticalRule)
+    {
+        return adoptRef(new CSSBorderImageValue(image, sliceRect, horizontalRule, verticalRule));
+    }
 
     virtual String cssText() const;
 
     CSSValue* imageValue() const { return m_image.get(); }
  
-public:
     // The border image.
     RefPtr<CSSValue> m_image;
 
@@ -52,6 +50,9 @@ public:
     // 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
+
+private:
+    CSSBorderImageValue(PassRefPtr<CSSValue> image, PassRefPtr<Rect> sliceRect, int horizontalRule, int verticalRule);
 };
 
 } // namespace WebCore
index 59fbf437dd928705dfdc5989cbfaf9d48a453de5..923279d862d8143feb977bce7af8bbeefc67db0e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #define CSSCanvasValue_h
 
 #include "CSSImageGeneratorValue.h"
-
-#include "CSSPrimitiveValue.h"
 #include "HTMLCanvasElement.h"
-#include "PlatformString.h"
-
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
 
 namespace WebCore {
 
 class Document;
 
-class CSSCanvasValue : public CSSImageGeneratorValue, public CanvasObserver {
+class CSSCanvasValue : public CSSImageGeneratorValue, private CanvasObserver {
 public:
-    CSSCanvasValue() {};
-    ~CSSCanvasValue();
+    static PassRefPtr<CSSCanvasValue> create() { return adoptRef(new CSSCanvasValue); }
+    virtual ~CSSCanvasValue();
 
     virtual String cssText() const;
 
@@ -50,12 +44,14 @@ public:
     virtual bool isFixedSize() const { return true; }
     virtual IntSize fixedSize(const RenderObject*);
 
+    void setName(const String& name) { m_name = name; }
+
+private:
+    CSSCanvasValue() { }
+
     virtual void canvasChanged(HTMLCanvasElement* element, const FloatRect& changedRect);
     virtual void canvasResized(HTMLCanvasElement* element);
 
-    void setName(const String& name) { m_name = name; }
-
-protected:
     HTMLCanvasElement* element(Document*);
      
     // The name of the canvas.
index ac0410831e275319438179b57d2126d14d8247c7..48229e4bd62ad17f2d692dcaaf81b8bd10e74fcc 100644 (file)
@@ -1,7 +1,5 @@
-/**
- * This file is part of the DOM implementation for KDE.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
+/*
+ * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Alexey Proskuryakov (ap@macrules.ru)
  *
  * This library is free software; you can redistribute it and/or
@@ -25,7 +23,7 @@
 
 namespace WebCore {
 
-CSSCharsetRule::CSSCharsetRule(StyleBase* parent, const String& encoding)
+CSSCharsetRule::CSSCharsetRule(CSSStyleSheet* parent, const String& encoding)
     : CSSRule(parent)
     , m_encoding(encoding)
 {
index d860ed383580b8b14f01f86b91975a64a7cdd8eb..07fb07588f6af3445a20e2692d2294539921af72 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * 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.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 namespace WebCore {
 
-typedef int ExceptionCode;
-
 class CSSCharsetRule : public CSSRule {
 public:
-    CSSCharsetRule(StyleBase* parent, const String& encoding);
-    virtual ~CSSCharsetRule();
+    static PassRefPtr<CSSCharsetRule> create(CSSStyleSheet* parent, const String& encoding)
+    {
+        return adoptRef(new CSSCharsetRule(parent, encoding));
+    }
 
-    virtual bool isCharsetRule() { return true; }
+    virtual ~CSSCharsetRule();
 
-    String encoding() const { return m_encoding; }
+    const String& encoding() const { return m_encoding; }
     void setEncoding(const String& encoding, ExceptionCode&) { m_encoding = encoding; }
 
-    // Inherited from CSSRule
-    virtual unsigned short type() const { return CHARSET_RULE; }
-
     virtual String cssText() const;
 
-protected:
+private:
+    CSSCharsetRule(CSSStyleSheet* parent, const String& encoding);
+
+    virtual bool isCharsetRule() { return true; }
+
+    // from CSSRule
+    virtual unsigned short type() const { return CHARSET_RULE; }
+
     String m_encoding;
 };
 
index 62ed1cbcc1b80de89244f72c01628cb179bea7a4..1b3cf09d3555d85e6aecb0185928a596d2b9eff5 100644 (file)
@@ -242,15 +242,15 @@ const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(compu
 static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow)
 {
     if (!shadow)
-        return new CSSPrimitiveValue(CSSValueNone);
+        return CSSPrimitiveValue::createIdentifier(CSSValueNone);
 
-    RefPtr<CSSValueList> list = new CSSValueList;
+    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     for (const ShadowData* s = shadow; s; s = s->next) {
-        RefPtr<CSSPrimitiveValue> x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX);
-        RefPtr<CSSPrimitiveValue> y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX);
-        RefPtr<CSSPrimitiveValue> blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX);
-        RefPtr<CSSPrimitiveValue> color = new CSSPrimitiveValue(s->color.rgb());
-        list->prepend(new ShadowValue(x.release(), y.release(), blur.release(), color.release()));
+        RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(s->x, CSSPrimitiveValue::CSS_PX);
+        RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(s->y, CSSPrimitiveValue::CSS_PX);
+        RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(s->blur, CSSPrimitiveValue::CSS_PX);
+        RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color.rgb());
+        list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), color.release()));
     }
     return list.release();
 }
@@ -270,7 +270,7 @@ static int valueForRepeatRule(int rule)
 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
 {
     if (!image.hasImage())
-        return new CSSPrimitiveValue(CSSValueNone);
+        return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     
     // Image first.
     RefPtr<CSSValue> imageValue;
@@ -280,27 +280,27 @@ static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
     // Create the slices.
     RefPtr<CSSPrimitiveValue> top;
     if (image.m_slices.top.isPercent())
-        top = new CSSPrimitiveValue(image.m_slices.top.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+        top = CSSPrimitiveValue::create(image.m_slices.top.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     else
-        top = new CSSPrimitiveValue(image.m_slices.top.value(), CSSPrimitiveValue::CSS_NUMBER);
+        top = CSSPrimitiveValue::create(image.m_slices.top.value(), CSSPrimitiveValue::CSS_NUMBER);
         
     RefPtr<CSSPrimitiveValue> right;
     if (image.m_slices.right.isPercent())
-        right = new CSSPrimitiveValue(image.m_slices.right.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+        right = CSSPrimitiveValue::create(image.m_slices.right.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     else
-        right = new CSSPrimitiveValue(image.m_slices.right.value(), CSSPrimitiveValue::CSS_NUMBER);
+        right = CSSPrimitiveValue::create(image.m_slices.right.value(), CSSPrimitiveValue::CSS_NUMBER);
         
     RefPtr<CSSPrimitiveValue> bottom;
     if (image.m_slices.bottom.isPercent())
-        bottom = new CSSPrimitiveValue(image.m_slices.bottom.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+        bottom = CSSPrimitiveValue::create(image.m_slices.bottom.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     else
-        bottom = new CSSPrimitiveValue(image.m_slices.bottom.value(), CSSPrimitiveValue::CSS_NUMBER);
+        bottom = CSSPrimitiveValue::create(image.m_slices.bottom.value(), CSSPrimitiveValue::CSS_NUMBER);
     
     RefPtr<CSSPrimitiveValue> left;
     if (image.m_slices.left.isPercent())
-        left = new CSSPrimitiveValue(image.m_slices.left.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
+        left = CSSPrimitiveValue::create(image.m_slices.left.value(), CSSPrimitiveValue::CSS_PERCENTAGE);
     else
-        left = new CSSPrimitiveValue(image.m_slices.left.value(), CSSPrimitiveValue::CSS_NUMBER);
+        left = CSSPrimitiveValue::create(image.m_slices.left.value(), CSSPrimitiveValue::CSS_NUMBER);
 
     RefPtr<Rect> rect = Rect::create();
     rect->setTop(top);
@@ -308,19 +308,19 @@ static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
     rect->setBottom(bottom);
     rect->setLeft(left);
 
-    return new CSSBorderImageValue(imageValue, rect, valueForRepeatRule(image.m_horizontalRule), valueForRepeatRule(image.m_verticalRule));
+    return CSSBorderImageValue::create(imageValue, rect, valueForRepeatRule(image.m_horizontalRule), valueForRepeatRule(image.m_verticalRule));
 }
 
 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection)
 {
     if (!reflection)
-        return new CSSPrimitiveValue(CSSValueNone);
+        return CSSPrimitiveValue::createIdentifier(CSSValueNone);
 
     RefPtr<CSSPrimitiveValue> offset;
     if (reflection->offset().isPercent())
-        offset = new CSSPrimitiveValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
+        offset = CSSPrimitiveValue::create(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
     else
-        offset = new CSSPrimitiveValue(reflection->offset().value(), CSSPrimitiveValue::CSS_PX);
+        offset = CSSPrimitiveValue::create(reflection->offset().value(), CSSPrimitiveValue::CSS_PX);
     
     return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask()));
 }
@@ -349,32 +349,32 @@ static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int prope
     }
 
     if (style->position() == AbsolutePosition || style->position() == FixedPosition)
-        return new CSSPrimitiveValue(l);
+        return CSSPrimitiveValue::create(l);
 
     if (style->position() == RelativePosition)
         // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
         // In other words if left is auto and right is not auto, then left's computed value is negative right.
         // So we should get the opposite length unit and see if it is auto.
-        return new CSSPrimitiveValue(l);
+        return CSSPrimitiveValue::create(l);
 
-    return new CSSPrimitiveValue(CSSValueAuto);
+    return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
 }
 
 static PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle* style, const Color& color)
 {
     if (!color.isValid())
-        return new CSSPrimitiveValue(style->color().rgb());
-    return new CSSPrimitiveValue(color.rgb());
+        return CSSPrimitiveValue::createColor(style->color().rgb());
+    return CSSPrimitiveValue::createColor(color.rgb());
 }
 
 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(IntSize radius)
 {
     if (radius.width() == radius.height())
-        return new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX);
+        return CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX);
 
-    RefPtr<CSSValueList> list = new CSSValueList(true);
-    list->append(new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX));
-    list->append(new CSSPrimitiveValue(radius.height(), CSSPrimitiveValue::CSS_PX));
+    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+    list->append(CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX));
+    list->append(CSSPrimitiveValue::create(radius.height(), CSSPrimitiveValue::CSS_PX));
     return list.release();
 }
 
@@ -439,56 +439,56 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             break;
 
         case CSSPropertyBackgroundColor:
-            return new CSSPrimitiveValue(style->backgroundColor().rgb());
+            return CSSPrimitiveValue::createColor(style->backgroundColor().rgb());
         case CSSPropertyBackgroundImage:
             if (style->backgroundImage())
                 return style->backgroundImage()->cssValue();
-            return new CSSPrimitiveValue(CSSValueNone);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyWebkitBackgroundSize: {
-            RefPtr<CSSValueList> list = new CSSValueList(true);
-            list->append(new CSSPrimitiveValue(style->backgroundSize().width));
-            list->append(new CSSPrimitiveValue(style->backgroundSize().height));
+            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+            list->append(CSSPrimitiveValue::create(style->backgroundSize().width));
+            list->append(CSSPrimitiveValue::create(style->backgroundSize().height));
             return list.release();
         }  
         case CSSPropertyBackgroundRepeat:
-            return new CSSPrimitiveValue(style->backgroundRepeat());
+            return CSSPrimitiveValue::create(style->backgroundRepeat());
         case CSSPropertyWebkitBackgroundComposite:
-            return new CSSPrimitiveValue(style->backgroundComposite());
+            return CSSPrimitiveValue::create(style->backgroundComposite());
         case CSSPropertyBackgroundAttachment:
             if (style->backgroundAttachment())
-                return new CSSPrimitiveValue(CSSValueScroll);
-            return new CSSPrimitiveValue(CSSValueFixed);
+                return CSSPrimitiveValue::createIdentifier(CSSValueScroll);
+            return CSSPrimitiveValue::createIdentifier(CSSValueFixed);
         case CSSPropertyWebkitBackgroundClip:
         case CSSPropertyWebkitBackgroundOrigin: {
             EFillBox box = (propertyID == CSSPropertyWebkitBackgroundClip ? style->backgroundClip() : style->backgroundOrigin());
-            return new CSSPrimitiveValue(box);
+            return CSSPrimitiveValue::create(box);
         }
         case CSSPropertyBackgroundPosition: {
-            RefPtr<CSSValueList> list = new CSSValueList(true);
+            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
 
-            list->append(new CSSPrimitiveValue(style->backgroundXPosition()));
-            list->append(new CSSPrimitiveValue(style->backgroundYPosition()));
+            list->append(CSSPrimitiveValue::create(style->backgroundXPosition()));
+            list->append(CSSPrimitiveValue::create(style->backgroundYPosition()));
 
             return list.release();
         }
         case CSSPropertyBackgroundPositionX:
-            return new CSSPrimitiveValue(style->backgroundXPosition());
+            return CSSPrimitiveValue::create(style->backgroundXPosition());
         case CSSPropertyBackgroundPositionY:
-            return new CSSPrimitiveValue(style->backgroundYPosition());
+            return CSSPrimitiveValue::create(style->backgroundYPosition());
         case CSSPropertyBorderCollapse:
             if (style->borderCollapse())
-                return new CSSPrimitiveValue(CSSValueCollapse);
-            return new CSSPrimitiveValue(CSSValueSeparate);
+                return CSSPrimitiveValue::createIdentifier(CSSValueCollapse);
+            return CSSPrimitiveValue::createIdentifier(CSSValueSeparate);
         case CSSPropertyBorderSpacing: {
-            RefPtr<CSSValueList> list = new CSSValueList(true);
-            list->append(new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
-            list->append(new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
+            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+            list->append(CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
+            list->append(CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX));
             return list.release();
         }  
         case CSSPropertyWebkitBorderHorizontalSpacing:
-            return new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyWebkitBorderVerticalSpacing:
-            return new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyBorderTopColor:
             return currentColorOrValidColor(style, style->borderTopColor());
         case CSSPropertyBorderRightColor:
@@ -498,88 +498,88 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyBorderLeftColor:
             return currentColorOrValidColor(style, style->borderLeftColor());
         case CSSPropertyBorderTopStyle:
-            return new CSSPrimitiveValue(style->borderTopStyle());
+            return CSSPrimitiveValue::create(style->borderTopStyle());
         case CSSPropertyBorderRightStyle:
-            return new CSSPrimitiveValue(style->borderRightStyle());
+            return CSSPrimitiveValue::create(style->borderRightStyle());
         case CSSPropertyBorderBottomStyle:
-            return new CSSPrimitiveValue(style->borderBottomStyle());
+            return CSSPrimitiveValue::create(style->borderBottomStyle());
         case CSSPropertyBorderLeftStyle:
-            return new CSSPrimitiveValue(style->borderLeftStyle());
+            return CSSPrimitiveValue::create(style->borderLeftStyle());
         case CSSPropertyBorderTopWidth:
-            return new CSSPrimitiveValue(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyBorderRightWidth:
-            return new CSSPrimitiveValue(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyBorderBottomWidth:
-            return new CSSPrimitiveValue(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyBorderLeftWidth:
-            return new CSSPrimitiveValue(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyBottom:
             return getPositionOffsetValue(style, CSSPropertyBottom);
         case CSSPropertyWebkitBoxAlign:
-            return new CSSPrimitiveValue(style->boxAlign());
+            return CSSPrimitiveValue::create(style->boxAlign());
         case CSSPropertyWebkitBoxDirection:
-            return new CSSPrimitiveValue(style->boxDirection());
+            return CSSPrimitiveValue::create(style->boxDirection());
         case CSSPropertyWebkitBoxFlex:
-            return new CSSPrimitiveValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitBoxFlexGroup:
-            return new CSSPrimitiveValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitBoxLines:
-            return new CSSPrimitiveValue(style->boxLines());
+            return CSSPrimitiveValue::create(style->boxLines());
         case CSSPropertyWebkitBoxOrdinalGroup:
-            return new CSSPrimitiveValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitBoxOrient:
-            return new CSSPrimitiveValue(style->boxOrient());
+            return CSSPrimitiveValue::create(style->boxOrient());
         case CSSPropertyWebkitBoxPack: {
             EBoxAlignment boxPack = style->boxPack();
             ASSERT(boxPack != BSTRETCH);
             ASSERT(boxPack != BBASELINE);
             if (boxPack == BJUSTIFY || boxPack== BBASELINE)
                 return 0;
-            return new CSSPrimitiveValue(boxPack);
+            return CSSPrimitiveValue::create(boxPack);
         }
         case CSSPropertyWebkitBoxReflect:
             return valueForReflection(style->boxReflect());
         case CSSPropertyWebkitBoxShadow:
             return valueForShadow(style->boxShadow());
         case CSSPropertyCaptionSide:
-            return new CSSPrimitiveValue(style->captionSide());
+            return CSSPrimitiveValue::create(style->captionSide());
         case CSSPropertyClear:
-            return new CSSPrimitiveValue(style->clear());
+            return CSSPrimitiveValue::create(style->clear());
         case CSSPropertyColor:
-            return new CSSPrimitiveValue(style->color().rgb());
+            return CSSPrimitiveValue::createColor(style->color().rgb());
         case CSSPropertyWebkitColumnCount:
             if (style->hasAutoColumnCount())
-                return new CSSPrimitiveValue(CSSValueAuto);
-            return new CSSPrimitiveValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
+                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
+            return CSSPrimitiveValue::create(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitColumnGap:
             if (style->hasNormalColumnGap())
-                return new CSSPrimitiveValue(CSSValueNormal);
-            return new CSSPrimitiveValue(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
+            return CSSPrimitiveValue::create(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitColumnRuleColor:
             return currentColorOrValidColor(style, style->columnRuleColor());
         case CSSPropertyWebkitColumnRuleStyle:
-            return new CSSPrimitiveValue(style->columnRuleStyle());
+            return CSSPrimitiveValue::create(style->columnRuleStyle());
         case CSSPropertyWebkitColumnRuleWidth:
-            return new CSSPrimitiveValue(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyWebkitColumnBreakAfter:
-            return new CSSPrimitiveValue(style->columnBreakAfter());
+            return CSSPrimitiveValue::create(style->columnBreakAfter());
         case CSSPropertyWebkitColumnBreakBefore:
-            return new CSSPrimitiveValue(style->columnBreakBefore());
+            return CSSPrimitiveValue::create(style->columnBreakBefore());
         case CSSPropertyWebkitColumnBreakInside:
-            return new CSSPrimitiveValue(style->columnBreakInside());
+            return CSSPrimitiveValue::create(style->columnBreakInside());
         case CSSPropertyWebkitColumnWidth:
             if (style->hasAutoColumnWidth())
-                return new CSSPrimitiveValue(CSSValueAuto);
-            return new CSSPrimitiveValue(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER);
+                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
+            return CSSPrimitiveValue::create(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyCursor: {
             RefPtr<CSSValueList> list;
             CursorList* cursors = style->cursors();
             if (cursors && cursors->size() > 0) {
-                list = new CSSValueList;
+                list = CSSValueList::createCommaSeparated();
                 for (unsigned i = 0; i < cursors->size(); ++i)
-                    list->append(new CSSPrimitiveValue((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI));
+                    list->append(CSSPrimitiveValue::create((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI));
             }
-            RefPtr<CSSValue> value = new CSSPrimitiveValue(style->cursor());
+            RefPtr<CSSValue> value = CSSPrimitiveValue::create(style->cursor());
             if (list) {
                 list->append(value);
                 return list.release();
@@ -587,229 +587,229 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return value.release();
         }
         case CSSPropertyDirection:
-            return new CSSPrimitiveValue(style->direction());
+            return CSSPrimitiveValue::create(style->direction());
         case CSSPropertyDisplay:
-            return new CSSPrimitiveValue(style->display());
+            return CSSPrimitiveValue::create(style->display());
         case CSSPropertyEmptyCells:
-            return new CSSPrimitiveValue(style->emptyCells());
+            return CSSPrimitiveValue::create(style->emptyCells());
         case CSSPropertyFloat:
-            return new CSSPrimitiveValue(style->floating());
+            return CSSPrimitiveValue::create(style->floating());
         case CSSPropertyFontFamily:
             // FIXME: This only returns the first family.
-            return new CSSPrimitiveValue(style->fontDescription().family().family().string(), CSSPrimitiveValue::CSS_STRING);
+            return CSSPrimitiveValue::create(style->fontDescription().family().family().string(), CSSPrimitiveValue::CSS_STRING);
         case CSSPropertyFontSize:
-            return new CSSPrimitiveValue(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyWebkitBinding:
             break;
         case CSSPropertyFontStyle:
             if (style->fontDescription().italic())
-                return new CSSPrimitiveValue(CSSValueItalic);
-            return new CSSPrimitiveValue(CSSValueNormal);
+                return CSSPrimitiveValue::createIdentifier(CSSValueItalic);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
         case CSSPropertyFontVariant:
             if (style->fontDescription().smallCaps())
-                return new CSSPrimitiveValue(CSSValueSmallCaps);
-            return new CSSPrimitiveValue(CSSValueNormal);
+                return CSSPrimitiveValue::createIdentifier(CSSValueSmallCaps);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
         case CSSPropertyFontWeight:
             switch (style->fontDescription().weight()) {
                 case FontWeight100:
-                    return new CSSPrimitiveValue(CSSValue100);
+                    return CSSPrimitiveValue::createIdentifier(CSSValue100);
                 case FontWeight200:
-                    return new CSSPrimitiveValue(CSSValue200);
+                    return CSSPrimitiveValue::createIdentifier(CSSValue200);
                 case FontWeight300:
-                    return new CSSPrimitiveValue(CSSValue300);
+                    return CSSPrimitiveValue::createIdentifier(CSSValue300);
                 case FontWeightNormal:
-                    return new CSSPrimitiveValue(CSSValueNormal);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
                 case FontWeight500:
-                    return new CSSPrimitiveValue(CSSValue500);
+                    return CSSPrimitiveValue::createIdentifier(CSSValue500);
                 case FontWeight600:
-                    return new CSSPrimitiveValue(CSSValue600);
+                    return CSSPrimitiveValue::createIdentifier(CSSValue600);
                 case FontWeightBold:
-                    return new CSSPrimitiveValue(CSSValueBold);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueBold);
                 case FontWeight800:
-                    return new CSSPrimitiveValue(CSSValue800);
+                    return CSSPrimitiveValue::createIdentifier(CSSValue800);
                 case FontWeight900:
-                    return new CSSPrimitiveValue(CSSValue900);
+                    return CSSPrimitiveValue::createIdentifier(CSSValue900);
             }
             ASSERT_NOT_REACHED();
-            return new CSSPrimitiveValue(CSSValueNormal);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
         case CSSPropertyHeight:
             if (renderer)
-                return new CSSPrimitiveValue(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->height());
+                return CSSPrimitiveValue::create(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->height());
         case CSSPropertyWebkitHighlight:
             if (style->highlight() == nullAtom)
-                return new CSSPrimitiveValue(CSSValueNone);
-            return new CSSPrimitiveValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
+            return CSSPrimitiveValue::create(style->highlight(), CSSPrimitiveValue::CSS_STRING);
         case CSSPropertyWebkitBorderFit:
             if (style->borderFit() == BorderFitBorder)
-                return new CSSPrimitiveValue(CSSValueBorder);
-            return new CSSPrimitiveValue(CSSValueLines);
+                return CSSPrimitiveValue::createIdentifier(CSSValueBorder);
+            return CSSPrimitiveValue::createIdentifier(CSSValueLines);
         case CSSPropertyLeft:
             return getPositionOffsetValue(style, CSSPropertyLeft);
         case CSSPropertyLetterSpacing:
             if (!style->letterSpacing())
-                return new CSSPrimitiveValue(CSSValueNormal);
-            return new CSSPrimitiveValue(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
+            return CSSPrimitiveValue::create(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyWebkitLineClamp:
             if (style->lineClamp() == -1)
-                return new CSSPrimitiveValue(CSSValueNone);
-            return new CSSPrimitiveValue(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
+            return CSSPrimitiveValue::create(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
         case CSSPropertyLineHeight: {
             Length length = style->lineHeight();
             if (length.isNegative())
-                return new CSSPrimitiveValue(CSSValueNormal);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
             if (length.isPercent())
                 // This is imperfect, because it doesn't include the zoom factor and the real computation
                 // for how high to be in pixels does include things like minimum font size and the zoom factor.
                 // On the other hand, since font-size doesn't include the zoom factor, we really can't do
                 // that here either.
-                return new CSSPrimitiveValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX);
+                return CSSPrimitiveValue::create(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::CSS_PX);
         }
         case CSSPropertyListStyleImage:
             if (style->listStyleImage())
                 return style->listStyleImage()->cssValue();
-            return new CSSPrimitiveValue(CSSValueNone);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyListStylePosition:
-            return new CSSPrimitiveValue(style->listStylePosition());
+            return CSSPrimitiveValue::create(style->listStylePosition());
         case CSSPropertyListStyleType:
-            return new CSSPrimitiveValue(style->listStyleType());
+            return CSSPrimitiveValue::create(style->listStyleType());
         case CSSPropertyMarginTop:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
-                return new CSSPrimitiveValue(renderer->marginTop(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->marginTop());
+                return CSSPrimitiveValue::create(renderer->marginTop(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->marginTop());
         case CSSPropertyMarginRight:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
-                return new CSSPrimitiveValue(renderer->marginRight(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->marginRight());
+                return CSSPrimitiveValue::create(renderer->marginRight(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->marginRight());
         case CSSPropertyMarginBottom:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
-                return new CSSPrimitiveValue(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->marginBottom());
+                return CSSPrimitiveValue::create(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->marginBottom());
         case CSSPropertyMarginLeft:
             if (renderer)
                 // FIXME: Supposed to return the percentage if percentage was specified.
-                return new CSSPrimitiveValue(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->marginLeft());
+                return CSSPrimitiveValue::create(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->marginLeft());
         case CSSPropertyWebkitMarqueeDirection:
-            return new CSSPrimitiveValue(style->marqueeDirection());
+            return CSSPrimitiveValue::create(style->marqueeDirection());
         case CSSPropertyWebkitMarqueeIncrement:
-            return new CSSPrimitiveValue(style->marqueeIncrement());
+            return CSSPrimitiveValue::create(style->marqueeIncrement());
         case CSSPropertyWebkitMarqueeRepetition:
             if (style->marqueeLoopCount() < 0)
-                return new CSSPrimitiveValue(CSSValueInfinite);
-            return new CSSPrimitiveValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
+                return CSSPrimitiveValue::createIdentifier(CSSValueInfinite);
+            return CSSPrimitiveValue::create(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitMarqueeStyle:
-            return new CSSPrimitiveValue(style->marqueeBehavior());
+            return CSSPrimitiveValue::create(style->marqueeBehavior());
         case CSSPropertyWebkitMaskImage:
             if (style->maskImage())
                 return style->maskImage()->cssValue();
-            return new CSSPrimitiveValue(CSSValueNone);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyWebkitMaskSize: {
-            RefPtr<CSSValueList> list = new CSSValueList(true);
-            list->append(new CSSPrimitiveValue(style->maskSize().width));
-            list->append(new CSSPrimitiveValue(style->maskSize().height));
+            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+            list->append(CSSPrimitiveValue::create(style->maskSize().width));
+            list->append(CSSPrimitiveValue::create(style->maskSize().height));
             return list.release();
         }  
         case CSSPropertyWebkitMaskRepeat:
-            return new CSSPrimitiveValue(style->maskRepeat());
+            return CSSPrimitiveValue::create(style->maskRepeat());
         case CSSPropertyWebkitMaskAttachment:
             if (style->maskAttachment())
-                return new CSSPrimitiveValue(CSSValueScroll);
-            return new CSSPrimitiveValue(CSSValueFixed);
+                return CSSPrimitiveValue::createIdentifier(CSSValueScroll);
+            return CSSPrimitiveValue::createIdentifier(CSSValueFixed);
         case CSSPropertyWebkitMaskComposite:
-            return new CSSPrimitiveValue(style->maskComposite());
+            return CSSPrimitiveValue::create(style->maskComposite());
         case CSSPropertyWebkitMaskClip:
         case CSSPropertyWebkitMaskOrigin: {
             EFillBox box = (propertyID == CSSPropertyWebkitMaskClip ? style->maskClip() : style->maskOrigin());
-            return new CSSPrimitiveValue(box);
+            return CSSPrimitiveValue::create(box);
         }
         case CSSPropertyWebkitMaskPosition: {
-            RefPtr<CSSValueList> list = new CSSValueList(true);
+            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
 
-            list->append(new CSSPrimitiveValue(style->maskXPosition()));
-            list->append(new CSSPrimitiveValue(style->maskYPosition()));
+            list->append(CSSPrimitiveValue::create(style->maskXPosition()));
+            list->append(CSSPrimitiveValue::create(style->maskYPosition()));
 
             return list.release();
         }
         case CSSPropertyWebkitMaskPositionX:
-            return new CSSPrimitiveValue(style->maskXPosition());
+            return CSSPrimitiveValue::create(style->maskXPosition());
         case CSSPropertyWebkitMaskPositionY:
-            return new CSSPrimitiveValue(style->maskYPosition());
+            return CSSPrimitiveValue::create(style->maskYPosition());
         case CSSPropertyWebkitUserModify:
-            return new CSSPrimitiveValue(style->userModify());
+            return CSSPrimitiveValue::create(style->userModify());
         case CSSPropertyMaxHeight: {
             const Length& maxHeight = style->maxHeight();
             if (maxHeight.isFixed() && maxHeight.value() == undefinedLength)
-                return new CSSPrimitiveValue(CSSValueNone);
-            return new CSSPrimitiveValue(maxHeight);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
+            return CSSPrimitiveValue::create(maxHeight);
         }
         case CSSPropertyMaxWidth: {
             const Length& maxWidth = style->maxHeight();
             if (maxWidth.isFixed() && maxWidth.value() == undefinedLength)
-                return new CSSPrimitiveValue(CSSValueNone);
-            return new CSSPrimitiveValue(maxWidth);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
+            return CSSPrimitiveValue::create(maxWidth);
         }
         case CSSPropertyMinHeight:
-            return new CSSPrimitiveValue(style->minHeight());
+            return CSSPrimitiveValue::create(style->minHeight());
         case CSSPropertyMinWidth:
-            return new CSSPrimitiveValue(style->minWidth());
+            return CSSPrimitiveValue::create(style->minWidth());
         case CSSPropertyOpacity:
-            return new CSSPrimitiveValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyOrphans:
-            return new CSSPrimitiveValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyOutlineColor:
             return currentColorOrValidColor(style, style->outlineColor());
         case CSSPropertyOutlineStyle:
             if (style->outlineStyleIsAuto())
-                return new CSSPrimitiveValue(CSSValueAuto);
-            return new CSSPrimitiveValue(style->outlineStyle());
+                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
+            return CSSPrimitiveValue::create(style->outlineStyle());
         case CSSPropertyOutlineWidth:
-            return new CSSPrimitiveValue(style->outlineWidth(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->outlineWidth(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyOverflow:
-            return new CSSPrimitiveValue(max(style->overflowX(), style->overflowY()));
+            return CSSPrimitiveValue::create(max(style->overflowX(), style->overflowY()));
         case CSSPropertyOverflowX:
-            return new CSSPrimitiveValue(style->overflowX());
+            return CSSPrimitiveValue::create(style->overflowX());
         case CSSPropertyOverflowY:
-            return new CSSPrimitiveValue(style->overflowY());
+            return CSSPrimitiveValue::create(style->overflowY());
         case CSSPropertyPaddingTop:
             if (renderer)
-                return new CSSPrimitiveValue(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->paddingTop());
+                return CSSPrimitiveValue::create(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->paddingTop());
         case CSSPropertyPaddingRight:
             if (renderer)
-                return new CSSPrimitiveValue(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->paddingRight());
+                return CSSPrimitiveValue::create(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->paddingRight());
         case CSSPropertyPaddingBottom:
             if (renderer)
-                return new CSSPrimitiveValue(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->paddingBottom());
+                return CSSPrimitiveValue::create(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->paddingBottom());
         case CSSPropertyPaddingLeft:
             if (renderer)
-                return new CSSPrimitiveValue(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->paddingLeft());
+                return CSSPrimitiveValue::create(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->paddingLeft());
         case CSSPropertyPageBreakAfter:
-            return new CSSPrimitiveValue(style->pageBreakAfter());
+            return CSSPrimitiveValue::create(style->pageBreakAfter());
         case CSSPropertyPageBreakBefore:
-            return new CSSPrimitiveValue(style->pageBreakBefore());
+            return CSSPrimitiveValue::create(style->pageBreakBefore());
         case CSSPropertyPageBreakInside: {
             EPageBreak pageBreak = style->pageBreakInside();
             ASSERT(pageBreak != PBALWAYS);
             if (pageBreak == PBALWAYS)
                 return 0;
-            return new CSSPrimitiveValue(style->pageBreakInside());
+            return CSSPrimitiveValue::create(style->pageBreakInside());
         }
         case CSSPropertyPosition:
-            return new CSSPrimitiveValue(style->position());
+            return CSSPrimitiveValue::create(style->position());
         case CSSPropertyRight:
             return getPositionOffsetValue(style, CSSPropertyRight);
         case CSSPropertyTableLayout:
-            return new CSSPrimitiveValue(style->tableLayout());
+            return CSSPrimitiveValue::create(style->tableLayout());
         case CSSPropertyTextAlign:
-            return new CSSPrimitiveValue(style->textAlign());
+            return CSSPrimitiveValue::create(style->textAlign());
         case CSSPropertyTextDecoration: {
             String string;
             if (style->textDecoration() & UNDERLINE)
@@ -830,8 +830,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 string += "blink";
             }
             if (!string.length())
-                return new CSSPrimitiveValue(CSSValueNone);
-            return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
+            return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_STRING);
         }
         case CSSPropertyWebkitTextDecorationsInEffect: {
             String string;
@@ -853,97 +853,97 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 string += "blink";
             }
             if (!string.length())
-                return new CSSPrimitiveValue(CSSValueNone);
-            return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
+            return CSSPrimitiveValue::create(string, CSSPrimitiveValue::CSS_STRING);
         }
         case CSSPropertyWebkitTextFillColor:
             return currentColorOrValidColor(style, style->textFillColor());
         case CSSPropertyTextIndent:
-            return new CSSPrimitiveValue(style->textIndent());
+            return CSSPrimitiveValue::create(style->textIndent());
         case CSSPropertyTextShadow:
             return valueForShadow(style->textShadow());
         case CSSPropertyWebkitTextSecurity:
-            return new CSSPrimitiveValue(style->textSecurity());
+            return CSSPrimitiveValue::create(style->textSecurity());
         case CSSPropertyWebkitTextSizeAdjust:
             if (style->textSizeAdjust())
-                return new CSSPrimitiveValue(CSSValueAuto);
-            return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyWebkitTextStrokeColor:
             return currentColorOrValidColor(style, style->textStrokeColor());
         case CSSPropertyWebkitTextStrokeWidth:
-            return new CSSPrimitiveValue(style->textStrokeWidth(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->textStrokeWidth(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyTextTransform:
-            return new CSSPrimitiveValue(style->textTransform());
+            return CSSPrimitiveValue::create(style->textTransform());
         case CSSPropertyTop:
             return getPositionOffsetValue(style, CSSPropertyTop);
         case CSSPropertyUnicodeBidi:
-            return new CSSPrimitiveValue(style->unicodeBidi());
+            return CSSPrimitiveValue::create(style->unicodeBidi());
         case CSSPropertyVerticalAlign:
             switch (style->verticalAlign()) {
                 case BASELINE:
-                    return new CSSPrimitiveValue(CSSValueBaseline);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueBaseline);
                 case MIDDLE:
-                    return new CSSPrimitiveValue(CSSValueMiddle);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueMiddle);
                 case SUB:
-                    return new CSSPrimitiveValue(CSSValueSub);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueSub);
                 case SUPER:
-                    return new CSSPrimitiveValue(CSSValueSuper);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueSuper);
                 case TEXT_TOP:
-                    return new CSSPrimitiveValue(CSSValueTextTop);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueTextTop);
                 case TEXT_BOTTOM:
-                    return new CSSPrimitiveValue(CSSValueTextBottom);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueTextBottom);
                 case TOP:
-                    return new CSSPrimitiveValue(CSSValueTop);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueTop);
                 case BOTTOM:
-                    return new CSSPrimitiveValue(CSSValueBottom);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueBottom);
                 case BASELINE_MIDDLE:
-                    return new CSSPrimitiveValue(CSSValueWebkitBaselineMiddle);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueWebkitBaselineMiddle);
                 case LENGTH:
-                    return new CSSPrimitiveValue(style->verticalAlignLength());
+                    return CSSPrimitiveValue::create(style->verticalAlignLength());
             }
             ASSERT_NOT_REACHED();
             return 0;
         case CSSPropertyVisibility:
-            return new CSSPrimitiveValue(style->visibility());
+            return CSSPrimitiveValue::create(style->visibility());
         case CSSPropertyWhiteSpace:
-            return new CSSPrimitiveValue(style->whiteSpace());
+            return CSSPrimitiveValue::create(style->whiteSpace());
         case CSSPropertyWidows:
-            return new CSSPrimitiveValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWidth:
             if (renderer)
-                return new CSSPrimitiveValue(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX);
-            return new CSSPrimitiveValue(style->width());
+                return CSSPrimitiveValue::create(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->width());
         case CSSPropertyWordBreak:
-            return new CSSPrimitiveValue(style->wordBreak());
+            return CSSPrimitiveValue::create(style->wordBreak());
         case CSSPropertyWordSpacing:
-            return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
+            return CSSPrimitiveValue::create(style->wordSpacing(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyWordWrap:
-            return new CSSPrimitiveValue(style->wordWrap());
+            return CSSPrimitiveValue::create(style->wordWrap());
         case CSSPropertyWebkitLineBreak:
-            return new CSSPrimitiveValue(style->khtmlLineBreak());
+            return CSSPrimitiveValue::create(style->khtmlLineBreak());
         case CSSPropertyWebkitNbspMode:
-            return new CSSPrimitiveValue(style->nbspMode());
+            return CSSPrimitiveValue::create(style->nbspMode());
         case CSSPropertyWebkitMatchNearestMailBlockquoteColor:
-            return new CSSPrimitiveValue(style->matchNearestMailBlockquoteColor());
+            return CSSPrimitiveValue::create(style->matchNearestMailBlockquoteColor());
         case CSSPropertyResize:
-            return new CSSPrimitiveValue(style->resize());
+            return CSSPrimitiveValue::create(style->resize());
         case CSSPropertyZIndex:
             if (style->hasAutoZIndex())
-                return new CSSPrimitiveValue(CSSValueAuto);
-            return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
+                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
+            return CSSPrimitiveValue::create(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyZoom:
-            return new CSSPrimitiveValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitBoxSizing:
             if (style->boxSizing() == CONTENT_BOX)
-                return new CSSPrimitiveValue(CSSValueContentBox);
-            return new CSSPrimitiveValue(CSSValueBorderBox);
+                return CSSPrimitiveValue::createIdentifier(CSSValueContentBox);
+            return CSSPrimitiveValue::createIdentifier(CSSValueBorderBox);
 #if ENABLE(DASHBOARD_SUPPORT)
         case CSSPropertyWebkitDashboardRegion:
         {
             const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
             unsigned count = regions.size();
             if (count == 1 && regions[0].type == StyleDashboardRegion::None)
-                return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::createIdentifier(CSSValueNone);
 
             RefPtr<DashboardRegion> firstRegion;
             DashboardRegion* previousRegion = 0;
@@ -953,10 +953,10 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
 
                 region->m_label = styleRegion.label;
                 LengthBox offset = styleRegion.offset;
-                region->setTop(new CSSPrimitiveValue(offset.top.value(), CSSPrimitiveValue::CSS_PX));
-                region->setRight(new CSSPrimitiveValue(offset.right.value(), CSSPrimitiveValue::CSS_PX));
-                region->setBottom(new CSSPrimitiveValue(offset.bottom.value(), CSSPrimitiveValue::CSS_PX));
-                region->setLeft(new CSSPrimitiveValue(offset.left.value(), CSSPrimitiveValue::CSS_PX));
+                region->setTop(CSSPrimitiveValue::create(offset.top.value(), CSSPrimitiveValue::CSS_PX));
+                region->setRight(CSSPrimitiveValue::create(offset.right.value(), CSSPrimitiveValue::CSS_PX));
+                region->setBottom(CSSPrimitiveValue::create(offset.bottom.value(), CSSPrimitiveValue::CSS_PX));
+                region->setLeft(CSSPrimitiveValue::create(offset.left.value(), CSSPrimitiveValue::CSS_PX));
                 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
                 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
 
@@ -966,11 +966,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                     firstRegion = region;
                 previousRegion = region.get();
             }
-            return new CSSPrimitiveValue(firstRegion.release());
+            return CSSPrimitiveValue::create(firstRegion.release());
         }
 #endif
         case CSSPropertyWebkitAppearance:
-            return new CSSPrimitiveValue(style->appearance());
+            return CSSPrimitiveValue::create(style->appearance());
         case CSSPropertyWebkitBorderImage:
             return valueForNinePieceImage(style->borderImage());
         case CSSPropertyWebkitMaskBoxImage:
@@ -979,17 +979,17 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             // Not a real style property -- used by the editing engine -- so has no computed value.
             break;
         case CSSPropertyWebkitMarginBottomCollapse:
-            return new CSSPrimitiveValue(style->marginBottomCollapse());
+            return CSSPrimitiveValue::create(style->marginBottomCollapse());
         case CSSPropertyWebkitMarginTopCollapse:
-            return new CSSPrimitiveValue(style->marginTopCollapse());
+            return CSSPrimitiveValue::create(style->marginTopCollapse());
         case CSSPropertyWebkitRtlOrdering:
             if (style->visuallyOrdered())
-                return new CSSPrimitiveValue(CSSValueVisual);
-            return new CSSPrimitiveValue(CSSValueLogical);
+                return CSSPrimitiveValue::createIdentifier(CSSValueVisual);
+            return CSSPrimitiveValue::createIdentifier(CSSValueLogical);
         case CSSPropertyWebkitUserDrag:
-            return new CSSPrimitiveValue(style->userDrag());
+            return CSSPrimitiveValue::create(style->userDrag());
         case CSSPropertyWebkitUserSelect:
-            return new CSSPrimitiveValue(style->userSelect());
+            return CSSPrimitiveValue::create(style->userSelect());
         case CSSPropertyWebkitBorderBottomLeftRadius:
             return getBorderRadiusCornerValue(style->borderBottomLeftRadius());
         case CSSPropertyWebkitBorderBottomRightRadius:
@@ -1002,11 +1002,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         {
             if (style->hasClip()) {
                 RefPtr<Rect> rect = Rect::create();
-                rect->setTop(new CSSPrimitiveValue(style->clip().top.value(), CSSPrimitiveValue::CSS_PX));
-                rect->setRight(new CSSPrimitiveValue(style->clip().right.value(), CSSPrimitiveValue::CSS_PX));
-                rect->setBottom(new CSSPrimitiveValue(style->clip().bottom.value(), CSSPrimitiveValue::CSS_PX));
-                rect->setLeft(new CSSPrimitiveValue(style->clip().left.value(), CSSPrimitiveValue::CSS_PX));
-                return new CSSPrimitiveValue(rect.release());
+                rect->setTop(CSSPrimitiveValue::create(style->clip().top.value(), CSSPrimitiveValue::CSS_PX));
+                rect->setRight(CSSPrimitiveValue::create(style->clip().right.value(), CSSPrimitiveValue::CSS_PX));
+                rect->setBottom(CSSPrimitiveValue::create(style->clip().bottom.value(), CSSPrimitiveValue::CSS_PX));
+                rect->setLeft(CSSPrimitiveValue::create(style->clip().left.value(), CSSPrimitiveValue::CSS_PX));
+                return CSSPrimitiveValue::create(rect.release());
             }
             return 0;
         }
@@ -1200,9 +1200,4 @@ PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable(
     return copy();
 }
 
-PassRefPtr<CSSComputedStyleDeclaration> computedStyle(Node* node)
-{
-    return new CSSComputedStyleDeclaration(node);
-}
-
 } // namespace WebCore
index b19455c0f30a0214c36b3b37b8c4cf8c279a2fc5..a9fd67b63642134faaeb6bc04f2931de64e8354b 100644 (file)
@@ -1,7 +1,6 @@
-/**
- *
- * Copyright (C)  2004  Zack Rusin <zack@kde.org>
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+/*
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 namespace WebCore {
 
 class CSSMutableStyleDeclaration;
-class CSSProperty;
-class RenderObject;
-class RenderStyle;
 
 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
 
 class CSSComputedStyleDeclaration : public CSSStyleDeclaration {
 public:
-    CSSComputedStyleDeclaration(PassRefPtr<Node>);
+    friend PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node>);
     virtual ~CSSComputedStyleDeclaration();
 
     virtual String cssText() const;
@@ -63,6 +59,8 @@ public:
     static void removeComputedInheritablePropertiesFrom(CSSMutableStyleDeclaration*);
 
 private:
+    CSSComputedStyleDeclaration(PassRefPtr<Node>);
+
     virtual void setCssText(const String&, ExceptionCode&);
 
     virtual String removeProperty(int propertyID, ExceptionCode&);
@@ -71,7 +69,10 @@ private:
     RefPtr<Node> m_node;
 };
 
-PassRefPtr<CSSComputedStyleDeclaration> computedStyle(Node*);
+inline PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node> node)
+{
+    return adoptRef(new CSSComputedStyleDeclaration(node));
+}
 
 } // namespace WebCore
 
index 7aa38f862d3e14c2e4af1b7c2c34ac6048b18658..6b336d3df35e60981b1427e5ec728ee5ee39dbfe 100644 (file)
@@ -34,7 +34,7 @@ class CSSCursorImageValue : public CSSImageValue {
 public:
     static PassRefPtr<CSSCursorImageValue> create(const String& url, const IntPoint& hotspot)
     {
-        return new CSSCursorImageValue(url, hotspot);
+        return adoptRef(new CSSCursorImageValue(url, hotspot));
     }
 
     virtual ~CSSCursorImageValue();
index b1ffc05d355fe5abca0f780870c26e4cbf9947ca..b7223988cfbd4524357ef1aed4e2dbb2e70763bc 100644 (file)
@@ -1,9 +1,7 @@
-/**
- * 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.
+ * Copyright (C) 2002, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -28,7 +26,7 @@
 
 namespace WebCore {
 
-CSSFontFaceRule::CSSFontFaceRule(StyleBase* parent)
+CSSFontFaceRule::CSSFontFaceRule(CSSStyleSheet* parent)
     : CSSRule(parent)
 {
 }
index bc551a64a43d201b36bf9d6a044cecd1ece8133f..14e0d1bc3cbb9d56455ec58cc586120282a8b5e1 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * 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.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -34,21 +32,31 @@ class CSSMutableStyleDeclaration;
 
 class CSSFontFaceRule : public CSSRule {
 public:
-    CSSFontFaceRule(StyleBase* parent);
-    virtual ~CSSFontFaceRule();
+    static PassRefPtr<CSSFontFaceRule> create()
+    {
+        return adoptRef(new CSSFontFaceRule(0));
+    }
+    static PassRefPtr<CSSFontFaceRule> create(CSSStyleSheet* parent)
+    {
+        return adoptRef(new CSSFontFaceRule(parent));
+    }
 
-    virtual bool isFontFaceRule() { return true; }
+    virtual ~CSSFontFaceRule();
 
     CSSMutableStyleDeclaration* style() const { return m_style.get(); }
 
-    // Inherited from CSSRule
-    virtual unsigned short type() const { return FONT_FACE_RULE; }
-
     virtual String cssText() const;
 
     void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);
 
-protected:
+private:
+    CSSFontFaceRule(CSSStyleSheet* parent);
+
+    virtual bool isFontFaceRule() { return true; }
+
+    // Inherited from CSSRule
+    virtual unsigned short type() const { return FONT_FACE_RULE; }
+
     RefPtr<CSSMutableStyleDeclaration> m_style;
 };
 
index 328f50552e33fea3410b1d7cecd661d3198b3cd5..f5730c150e28cf1f83b3aaed91fd2242b6c2c511 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,6 +28,7 @@
 
 #include "CSSValue.h"
 #include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
 
 #if ENABLE(SVG_FONTS)
 #include "SVGFontFaceElement.h"
@@ -37,10 +38,16 @@ namespace WebCore {
 
 class CSSFontFaceSrcValue : public CSSValue {
 public:
-    CSSFontFaceSrcValue(const String& resource, bool local)
-    :m_resource(resource), m_isLocal(local)
-    {}
-    virtual ~CSSFontFaceSrcValue() {}
+    static PassRefPtr<CSSFontFaceSrcValue> create(const String& resource)
+    {
+        return adoptRef(new CSSFontFaceSrcValue(resource, false));
+    }
+    static PassRefPtr<CSSFontFaceSrcValue> createLocal(const String& resource)
+    {
+        return adoptRef(new CSSFontFaceSrcValue(resource, true));
+    }
+
+    virtual ~CSSFontFaceSrcValue() { }
 
     const String& resource() const { return m_resource; }
     const String& format() const { return m_format; }
@@ -60,6 +67,11 @@ public:
     virtual String cssText() const;
 
 private:
+    CSSFontFaceSrcValue(const String& resource, bool local)
+        : m_resource(resource), m_isLocal(local)
+    {
+    }
+
     String m_resource;
     String m_format;
     bool m_isLocal;
index ddc3d83c3e324bd24afc6de2dd010aa9fd473780..b90d3079c214c5cedaa1c693fea44be2aa4469b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,9 +27,7 @@
 #define CSSGradientValue_h
 
 #include "CSSImageGeneratorValue.h"
-
 #include "CSSPrimitiveValue.h"
-
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
@@ -42,8 +40,9 @@ enum CSSGradientType { CSSLinearGradient, CSSRadialGradient };
 
 struct CSSGradientColorStop {
     CSSGradientColorStop()
-    : m_stop(0)
-    {}
+        : m_stop(0)
+    {
+    }
     
     float m_stop;
     RefPtr<CSSPrimitiveValue> m_color;
@@ -51,11 +50,11 @@ struct CSSGradientColorStop {
 
 class CSSGradientValue : public CSSImageGeneratorValue {
 public:
-    CSSGradientValue()
-    : m_type(CSSLinearGradient)
-    , m_stopsSorted(false)
-    {}
-    
+    static PassRefPtr<CSSGradientValue> create()
+    {
+        return adoptRef(new CSSGradientValue);
+    }
+
     virtual String cssText() const;
 
     virtual Image* image(RenderObject*, const IntSize&);
@@ -75,7 +74,13 @@ public:
 
     void sortStopsIfNeeded();
 
-protected:
+private:
+    CSSGradientValue()
+        : m_type(CSSLinearGradient)
+        , m_stopsSorted(false)
+    {
+    }
+    
     // Create the gradient for a given size.
     Gradient* createGradient(RenderObject*, const IntSize&);
     
index 6acd5a8b615be5563e3082ac561b36b5706be3b8..b2f9ce1993cd056eb77385e81795828b5dffb781 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #define CSSImageGeneratorValue_h
 
 #include "CSSValue.h"
-
-#include "IntSize.h"
 #include "IntSizeHash.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashCountedSet.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
 
 namespace WebCore {
 
 class Image;
-class IntSize;
 class StyleGeneratedImage;
 class RenderObject;
 
 class CSSImageGeneratorValue : public CSSValue {
 public:
-    CSSImageGeneratorValue();
     virtual ~CSSImageGeneratorValue();
 
-    virtual bool isImageGeneratorValue() const { return true; }
-    
     void addClient(RenderObject*, const IntSize&);
     void removeClient(RenderObject*);
     virtual Image* image(RenderObject*, const IntSize&) = 0;
 
-    virtual StyleGeneratedImage* generatedImage();
+    StyleGeneratedImage* generatedImage();
     
     virtual bool isFixedSize() const { return false; }
     virtual IntSize fixedSize(const RenderObject*) { return IntSize(); }
     
 protected:
+    CSSImageGeneratorValue();
+    
     Image* getImage(RenderObject*, const IntSize&);
     void putImage(const IntSize&, Image*);
 
@@ -69,6 +63,9 @@ protected:
     
     RefPtr<StyleGeneratedImage> m_image;
     bool m_accessedImage;
+
+private:
+    virtual bool isImageGeneratorValue() const { return true; }
 };
 
 } // namespace WebCore
index fc600d20d67d18297e2d13cf59c1505128725637..a1715cd9ad10d19ee10e4bfff5c3de270598c694 100644 (file)
@@ -32,8 +32,8 @@ class StyleCachedImage;
 
 class CSSImageValue : public CSSPrimitiveValue, private CachedResourceClient {
 public:
-    static PassRefPtr<CSSImageValue> create() { return new CSSImageValue; }
-    static PassRefPtr<CSSImageValue> create(const String& url) { return new CSSImageValue(url); }
+    static PassRefPtr<CSSImageValue> create() { return adoptRef(new CSSImageValue); }
+    static PassRefPtr<CSSImageValue> create(const String& url) { return adoptRef(new CSSImageValue(url)); }
     virtual ~CSSImageValue();
 
     virtual StyleCachedImage* cachedImage(DocLoader*);
index 9dd00eb4cc0733b0c3f606c42ba29247ee703fc3..6f3d33174d0af2cc5f624fb96896464dab062c1d 100644 (file)
@@ -1,9 +1,7 @@
-/**
- * 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.
+ * Copyright (C) 2002, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "CSSImportRule.h"
 
 #include "CachedCSSStyleSheet.h"
-#include "CSSStyleSheet.h"
 #include "DocLoader.h"
 #include "Document.h"
 #include "MediaList.h"
 
 namespace WebCore {
 
-CSSImportRule::CSSImportRule(StyleBase* parent, const String& href, MediaList* media)
+CSSImportRule::CSSImportRule(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaList> media)
     : CSSRule(parent)
     , m_strHref(href)
     , m_lstMedia(media)
@@ -42,7 +39,7 @@ CSSImportRule::CSSImportRule(StyleBase* parent, const String& href, MediaList* m
     if (m_lstMedia)
         m_lstMedia->setParent(this);
     else
-        m_lstMedia = new MediaList(this, String());
+        m_lstMedia = MediaList::create(this, String());
 }
 
 CSSImportRule::~CSSImportRule()
@@ -59,7 +56,7 @@ void CSSImportRule::setCSSStyleSheet(const String& url, const String& charset, c
 {
     if (m_styleSheet)
         m_styleSheet->setParent(0);
-    m_styleSheet = new CSSStyleSheet(this, url, charset);
+    m_styleSheet = CSSStyleSheet::create(this, url, charset);
 
     CSSStyleSheet* parent = parentStyleSheet();
     bool strict = !parent || parent->useStrictParsing();
index ea40584b8ad0df8762279d716c57072f1ccf326c..1c94ac32f9e14ffc8c6861f46425119a552c3933 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * 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.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -26,6 +24,7 @@
 
 #include "CSSRule.h"
 #include "CachedResourceClient.h"
+#include "MediaList.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -33,31 +32,36 @@ namespace WebCore {
 class CachedCSSStyleSheet;
 class MediaList;
 
-class CSSImportRule : public CSSRule, public CachedResourceClient {
+class CSSImportRule : public CSSRule, private CachedResourceClient {
 public:
-    CSSImportRule(StyleBase* parent, const String& href, MediaList*);
-    virtual ~CSSImportRule();
+    static PassRefPtr<CSSImportRule> create(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaList> media)
+    {
+        return adoptRef(new CSSImportRule(parent, href, media));
+    }
 
-    virtual bool isImportRule() { return true; }
+    virtual ~CSSImportRule();
 
     String href() const { return m_strHref; }
     MediaList* media() const { return m_lstMedia.get(); }
     CSSStyleSheet* styleSheet() const { return m_styleSheet.get(); }
 
-    // Inherited from CSSRule
-    virtual unsigned short type() const { return IMPORT_RULE; }
-
     virtual String cssText() const;
 
     // Not part of the CSSOM
     bool isLoading() const;
 
-    // from CachedResourceClient
-    virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*);
+private:
+    CSSImportRule(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaList>);
 
+    virtual bool isImportRule() { return true; }
     virtual void insertedIntoParent();
 
-protected:
+    // from CSSRule
+    virtual unsigned short type() const { return IMPORT_RULE; }
+
+    // from CachedResourceClient
+    virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*);
+
     String m_strHref;
     RefPtr<MediaList> m_lstMedia;
     RefPtr<CSSStyleSheet> m_styleSheet;
index a2332d2086db91fbebf293f5296c3e1c6b6a9880..e015a98fd6271803c08c37c06e0ed12a31a6a80c 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #define CSSInheritedValue_h
 
 #include "CSSValue.h"
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
 class CSSInheritedValue : public CSSValue {
 public:
-    virtual unsigned short cssValueType() const;
+    static PassRefPtr<CSSInheritedValue> create()
+    {
+        return adoptRef(new CSSInheritedValue);
+    }
+
     virtual String cssText() const;
+
+private:
+    CSSInheritedValue() { }
+    virtual unsigned short cssValueType() const;
 };
 
 } // namespace WebCore
index 1e040152ce78f76cf42d01344f803e6de598780a..c099a3c1efda6da088b00f7b10b6339a480a2347 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #define CSSInitialValue_h
 
 #include "CSSValue.h"
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
 class CSSInitialValue : public CSSValue {
 public:
-    CSSInitialValue(bool implicit)
-    :m_implicit(implicit)
-    {}
+    static PassRefPtr<CSSInitialValue> createExplicit()
+    {
+        return adoptRef(new CSSInitialValue(false));
+    }
+    static PassRefPtr<CSSInitialValue> createImplicit()
+    {
+        return adoptRef(new CSSInitialValue(true));
+    }
 
-    virtual unsigned short cssValueType() const;
     virtual String cssText() const;
         
+private:
+    CSSInitialValue(bool implicit)
+        : m_implicit(implicit)
+    {
+    }
+
+    virtual unsigned short cssValueType() const;
     virtual bool isImplicitInitialValue() const { return m_implicit; }
 
-private:
     bool m_implicit;
 };
 
index 8cfc09a8e6b2602e51ce511419d2eb075c7ce0d3..610e9880963d855f675b3f4e763837f7a5799b5a 100644 (file)
 #include "CSSMediaRule.h"
 
 #include "CSSParser.h"
-#include "CSSRuleList.h"
 #include "ExceptionCode.h"
-#include "MediaList.h"
-#include "StyleSheet.h"
 
 namespace WebCore {
 
-CSSMediaRule::CSSMediaRule(StyleBase* parent, MediaList* mediaList, CSSRuleList* ruleList)
+CSSMediaRule::CSSMediaRule(CSSStyleSheet* parent, PassRefPtr<MediaList> media, PassRefPtr<CSSRuleList> rules)
     : CSSRule(parent)
-    , m_lstMedia(mediaList)
-    , m_lstCSSRules(ruleList)
-{
-}
-
-CSSMediaRule::CSSMediaRule(StyleBase* parent)
-    : CSSRule(parent)
-    , m_lstMedia(0)
-    , m_lstCSSRules(CSSRuleList::create())
-
-{
-}
-
-CSSMediaRule::CSSMediaRule(StyleBase* parent, const String &media)
-    : CSSRule(parent)
-    , m_lstMedia(new MediaList(this, media))
-    , m_lstCSSRules(CSSRuleList::create())
+    , m_lstMedia(media)
+    , m_lstCSSRules(rules)
 {
 }
 
index f6a7e4819a1a1b3ad14be90695ab36d29dbf2501..5eead7c2b96b687f5464a2f9bfbd1ce396306429 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * 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.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
  *
  * This library is free software; you can redistribute it and/or
 #define CSSMediaRule_h
 
 #include "CSSRule.h"
-#include <wtf/RefPtr.h>
+#include "CSSRuleList.h"
+#include "MediaList.h"
+#include "PlatformString.h" // needed so bindings will compile
 
 namespace WebCore {
 
 class CSSRuleList;
 class MediaList;
 
-typedef int ExceptionCode;
-
 class CSSMediaRule : public CSSRule {
 public:
-    CSSMediaRule(StyleBase* parent);
-    CSSMediaRule(StyleBase* parent, const String& media);
-    CSSMediaRule(StyleBase* parent, MediaList* mediaList, CSSRuleList* ruleList);
+    static PassRefPtr<CSSMediaRule> create(CSSStyleSheet* parent, PassRefPtr<MediaList> media, PassRefPtr<CSSRuleList> rules)
+    {
+        return adoptRef(new CSSMediaRule(parent, media, rules));
+    }
     virtual ~CSSMediaRule();
 
-    virtual bool isMediaRule() { return true; }
-
     MediaList* media() const { return m_lstMedia.get(); }
     CSSRuleList* cssRules() { return m_lstCSSRules.get(); }
 
     unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
     void deleteRule(unsigned index, ExceptionCode&);
 
-    // Inherited from CSSRule
-    virtual unsigned short type() const { return MEDIA_RULE; }
-
     virtual String cssText() const;
 
     // Not part of the CSSOM
     unsigned append(CSSRule*);
 
-protected:
+private:
+    CSSMediaRule(CSSStyleSheet* parent, PassRefPtr<MediaList>, PassRefPtr<CSSRuleList>);
+
+    virtual bool isMediaRule() { return true; }
+
+    // Inherited from CSSRule
+    virtual unsigned short type() const { return MEDIA_RULE; }
+
     RefPtr<MediaList> m_lstMedia;
     RefPtr<CSSRuleList> m_lstCSSRules;
 };
index e4640333a0cc785b533eca453660d96a948ad5c8..cd7e2d7377bb83ae071570d377722a4886b315fc 100644 (file)
@@ -609,7 +609,7 @@ bool CSSMutableStyleDeclaration::setProperty(int propertyID, const String& value
 bool CSSMutableStyleDeclaration::setProperty(int propertyID, int value, bool important, bool notifyChanged)
 {
     removeProperty(propertyID);
-    m_values.append(CSSProperty(propertyID, new CSSPrimitiveValue(value), important));
+    m_values.append(CSSProperty(propertyID, CSSPrimitiveValue::createIdentifier(value), important));
     if (notifyChanged)
         setChanged();
     return true;
@@ -618,7 +618,7 @@ bool CSSMutableStyleDeclaration::setProperty(int propertyID, int value, bool imp
 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));
+    m_values.append(CSSProperty(propertyId, CSSPrimitiveValue::create(value, type), important));
     setChanged();
 }
 
index 6719a64053b7b83fa1955b9ea77e9cde26cc7b0f..2470200bbbc6ed65ee469302991ef0118ebe6f02 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -26,7 +24,6 @@
 #include "CSSStyleDeclaration.h"
 #include "CSSPrimitiveValue.h"
 #include "DeprecatedValueList.h"
-#include "Node.h"
 #include "PlatformString.h"
 
 namespace WebCore {
@@ -36,10 +33,18 @@ 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);
+    static PassRefPtr<CSSMutableStyleDeclaration> create()
+    {
+        return adoptRef(new CSSMutableStyleDeclaration);
+    }
+    static PassRefPtr<CSSMutableStyleDeclaration> create(CSSRule* parentRule, const CSSProperty* const* properties, int numProperties)
+    {
+        return adoptRef(new CSSMutableStyleDeclaration(parentRule, properties, numProperties));
+    }
+    static PassRefPtr<CSSMutableStyleDeclaration> create(const DeprecatedValueList<CSSProperty>& properties)
+    {
+        return adoptRef(new CSSMutableStyleDeclaration(0, properties));
+    }
 
     CSSMutableStyleDeclaration& operator=(const CSSMutableStyleDeclaration&);
 
@@ -61,7 +66,6 @@ public:
     virtual String removeProperty(int propertyID, ExceptionCode&);
 
     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
-    virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
 
     DeprecatedValueListConstIterator<CSSProperty> valuesIterator() const { return m_values.begin(); }
 
@@ -100,7 +104,16 @@ public:
 
     void merge(CSSMutableStyleDeclaration*, bool argOverridesOnConflict = true);
 
+protected:
+    CSSMutableStyleDeclaration(CSSRule* parentRule);
+
 private:
+    CSSMutableStyleDeclaration();
+    CSSMutableStyleDeclaration(CSSRule* parentRule, const DeprecatedValueList<CSSProperty>&);
+    CSSMutableStyleDeclaration(CSSRule* parentRule, const CSSProperty* const *, int numProperties);
+
+    virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
+
     void setChanged();
 
     String getShorthandValue(const int* properties, int number) const;
index 4e954735aa475f76b11808602e81f102439060c4..6a37963b0051963350cf13eda916b49bb37f78e9 100644 (file)
@@ -1,9 +1,7 @@
-/**
- * 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.
+ * Copyright (C) 2002, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -28,7 +26,7 @@
 
 namespace WebCore {
 
-CSSPageRule::CSSPageRule(StyleBase* parent)
+CSSPageRule::CSSPageRule(CSSStyleSheet* parent)
     : CSSRule(parent)
 {
 }
index afa78c14e7a3abb508b7a980d34345a2da2ade3f..8e374a5c465373ab42e9a929fd1438efacfab01d 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * 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.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #define CSSPageRule_h
 
 #include "CSSRule.h"
+#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
 class CSSMutableStyleDeclaration;
 
-typedef int ExceptionCode;
-
 class CSSPageRule : public CSSRule {
 public:
-    CSSPageRule(StyleBase* parent);
-    virtual ~CSSPageRule();
+    static PassRefPtr<CSSPageRule> create(CSSStyleSheet* parent)
+    {
+        return adoptRef(new CSSPageRule(parent));
+    }
 
-    virtual bool isPageRule() { return true; }
+    virtual ~CSSPageRule();
 
     String selectorText() const;
     void setSelectorText(const String&, ExceptionCode&);
 
     CSSMutableStyleDeclaration* style() const { return m_style.get(); }
 
+    virtual String cssText() const;
+
+private:
+    CSSPageRule(CSSStyleSheet* parent);
+
     // Inherited from CSSRule
     virtual unsigned short type() const { return PAGE_RULE; }
 
-    virtual String cssText() const;
-
-protected:
     RefPtr<CSSMutableStyleDeclaration> m_style;
 };
 
index 291fc80b1acc5783f20ac7be78764f5c93de3879..3a206f11c29048b1bf2118f2752d061b7852d449 100644 (file)
@@ -265,7 +265,7 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
 
     // First try creating a color specified by name or the "#" syntax.
     if (!parser.parseColor(string, color, strict)) {
-        RefPtr<CSSMutableStyleDeclaration> dummyStyleDeclaration(new CSSMutableStyleDeclaration);
+        RefPtr<CSSMutableStyleDeclaration> dummyStyleDeclaration = CSSMutableStyleDeclaration::create();
 
         // Now try to create a color from the rgb() or rgba() syntax.
         if (parser.parseColor(dummyStyleDeclaration.get(), string)) {
@@ -506,13 +506,13 @@ bool CSSParser::parseValue(int propId, bool important)
     if (id == CSSValueInherit) {
         if (num != 1)
             return false;
-        addProperty(propId, new CSSInheritedValue(), important);
+        addProperty(propId, CSSInheritedValue::create(), important);
         return true;
     }
     else if (id == CSSValueInitial) {
         if (num != 1)
             return false;
-        addProperty(propId, new CSSInitialValue(false), important);
+        addProperty(propId, CSSInitialValue::createExplicit(), important);
         return true;
     }
 
@@ -788,7 +788,7 @@ bool CSSParser::parseValue(int propId, bool important)
         RefPtr<CSSValueList> list;
         while (value && value->unit == CSSPrimitiveValue::CSS_URI) {
             if (!list)
-                list = new CSSValueList
+                list = CSSValueList::createCommaSeparated()
             String uri = parseURL(value->string);
             Vector<int> coords;
             value = m_valueList->next();
@@ -816,9 +816,9 @@ bool CSSParser::parseValue(int propId, bool important)
                 if (list->length() != 1)
                     return false;
             } else if (!m_strict && value->id == CSSValueHand) // MSIE 5 compatibility :/
-                list->append(new CSSPrimitiveValue(CSSValuePointer));
+                list->append(CSSPrimitiveValue::createIdentifier(CSSValuePointer));
             else if (value && ((value->id >= CSSValueAuto && value->id <= CSSValueAllScroll) || value->id == CSSValueCopy || value->id == CSSValueNone))
-                list->append(new CSSPrimitiveValue(value->id));
+                list->append(CSSPrimitiveValue::createIdentifier(value->id));
             m_valueList->next();
             parsedValue = list.release();
             break;
@@ -1030,7 +1030,7 @@ bool CSSParser::parseValue(int propId, bool important)
         if (id == CSSValueNone) {
             valid_primitive = true;
         } else {
-            RefPtr<CSSValueList> list(new CSSValueList);
+            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
             bool is_valid = true;
             while(is_valid && value) {
                 switch (value->id) {
@@ -1039,7 +1039,7 @@ bool CSSParser::parseValue(int propId, bool important)
                 case CSSValueUnderline:
                 case CSSValueOverline:
                 case CSSValueLineThrough:
-                    list->append(new CSSPrimitiveValue(value->id));
+                    list->append(CSSPrimitiveValue::createIdentifier(value->id));
                     break;
                 default:
                     is_valid = false;
@@ -1082,13 +1082,13 @@ bool CSSParser::parseValue(int propId, bool important)
         if (id == CSSValueNone)
             valid_primitive = true;
         else {
-            RefPtr<CSSValueList> values(new CSSValueList());
+            RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
             Value* val;
             RefPtr<CSSValue> parsedValue;
             while ((val = m_valueList->current())) {
                 if (val->unit == CSSPrimitiveValue::CSS_URI) {
                     String value = parseURL(val->string);
-                    parsedValue = new CSSPrimitiveValue(KURL(m_styleSheet->baseURL(), value).string(),
+                    parsedValue = CSSPrimitiveValue::create(KURL(m_styleSheet->baseURL(), value).string(),
                         CSSPrimitiveValue::CSS_URI);
                 }
                 if (!parsedValue)
@@ -1133,19 +1133,19 @@ bool CSSParser::parseValue(int propId, bool important)
         valid_primitive = validUnit(value, FLength, m_strict);
         if (!valid_primitive)
             return false;
-        RefPtr<CSSPrimitiveValue> parsedValue1 = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+        RefPtr<CSSPrimitiveValue> parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
         RefPtr<CSSPrimitiveValue> parsedValue2;
         if (num == 2) {
             value = m_valueList->next();
             valid_primitive = validUnit(value, FLength, m_strict);
             if (!valid_primitive)
                 return false;
-            parsedValue2 = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+            parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
         } else
             parsedValue2 = parsedValue1;
         
         RefPtr<Pair> pair = Pair::create(parsedValue1.release(), parsedValue2.release());
-        RefPtr<CSSPrimitiveValue> val = new CSSPrimitiveValue(pair.release());
+        RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(pair.release());
         if (propId == CSSPropertyWebkitBorderRadius) {
             const int properties[4] = { CSSPropertyWebkitBorderTopRightRadius,
                                         CSSPropertyWebkitBorderTopLeftRadius,
@@ -1562,13 +1562,13 @@ bool CSSParser::parseValue(int propId, bool important)
 
     if (valid_primitive) {
         if (id != 0)
-            parsedValue = new CSSPrimitiveValue(id);
+            parsedValue = CSSPrimitiveValue::createIdentifier(id);
         else if (value->unit == CSSPrimitiveValue::CSS_STRING)
-            parsedValue = new CSSPrimitiveValue(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
+            parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
         else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
-            parsedValue = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
+            parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
         else if (value->unit >= Value::Q_EMS)
-            parsedValue = new CSSQuirkPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_EMS);
+            parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
         m_valueList->next();
     }
     if (parsedValue) {
@@ -1587,7 +1587,7 @@ void CSSParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue> rval)
             static_cast<CSSValueList*>(lval.get())->append(rval);
         else {
             PassRefPtr<CSSValue> oldlVal(lval.release());
-            PassRefPtr<CSSValueList> list(new CSSValueList());
+            PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
             list->append(oldlVal);
             list->append(rval);
             lval = list;
@@ -1624,9 +1624,9 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
                     return false;
 
                 if (!parsedProperty[i] && properties[i] != CSSPropertyBackgroundColor) {
-                    addFillValue(values[i], new CSSInitialValue(true));
+                    addFillValue(values[i], CSSInitialValue::createImplicit());
                     if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
-                        addFillValue(positionYValue, new CSSInitialValue(true));
+                        addFillValue(positionYValue, CSSInitialValue::createImplicit());
                 }
                 parsedProperty[i] = false;
             }
@@ -1658,9 +1658,9 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
     // Fill in any remaining properties with the initial value.
     for (i = 0; i < numProperties; ++i) {
         if (!parsedProperty[i]) {
-            addFillValue(values[i], new CSSInitialValue(true));
+            addFillValue(values[i], CSSInitialValue::createImplicit());
             if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
-                addFillValue(positionYValue, new CSSInitialValue(true));
+                addFillValue(positionYValue, CSSInitialValue::createImplicit());
         }
     }
     
@@ -1688,7 +1688,7 @@ void CSSParser::addTransitionValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue>
             static_cast<CSSValueList*>(lval.get())->append(rval);
         else {
             PassRefPtr<CSSValue> oldVal(lval.release());
-            PassRefPtr<CSSValueList> list(new CSSValueList());
+            PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
             list->append(oldVal);
             list->append(rval);
             lval = list;
@@ -1717,7 +1717,7 @@ bool CSSParser::parseTransitionShorthand(bool important)
             m_valueList->next();
             for (i = 0; i < numProperties; ++i) {
                 if (!parsedProperty[i])
-                    addTransitionValue(values[i], new CSSInitialValue(true));
+                    addTransitionValue(values[i], CSSInitialValue::createImplicit());
                 parsedProperty[i] = false;
             }
             if (!m_valueList->current())
@@ -1744,7 +1744,7 @@ bool CSSParser::parseTransitionShorthand(bool important)
     // Fill in any remaining properties with the initial value.
     for (i = 0; i < numProperties; ++i) {
         if (!parsedProperty[i])
-            addTransitionValue(values[i], new CSSInitialValue(true));
+            addTransitionValue(values[i], CSSInitialValue::createImplicit());
     }
     
     // Now add all of the properties we found.
@@ -1785,7 +1785,7 @@ bool CSSParser::parseShorthand(int propId, const int *properties, int numPropert
     m_implicitShorthand = true;
     for (int i = 0; i < numProperties; ++i) {
         if (!fnd[i])
-            addProperty(properties[i], new CSSInitialValue(true), important);
+            addProperty(properties[i], CSSInitialValue::createImplicit(), important);
     }
     m_implicitShorthand = false;
 
@@ -1858,7 +1858,7 @@ bool CSSParser::parse4Values(int propId, const int *properties,  bool important)
 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
 bool CSSParser::parseContent(int propId, bool important)
 {
-    RefPtr<CSSValueList> values = new CSSValueList;
+    RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
 
     while (Value* val = m_valueList->current()) {
         RefPtr<CSSValue> parsedValue;
@@ -1878,7 +1878,7 @@ bool CSSParser::parseContent(int propId, bool important)
                 String attrName = a->string;
                 if (document()->isHTMLDocument())
                     attrName = attrName.lower();
-                parsedValue = new CSSPrimitiveValue(attrName, CSSPrimitiveValue::CSS_ATTR);
+                parsedValue = CSSPrimitiveValue::create(attrName, CSSPrimitiveValue::CSS_ATTR);
             } else if (equalIgnoringCase(val->function->name, "counter(")) {
                 parsedValue = parseCounterContent(args, false);
                 if (!parsedValue) return false;
@@ -1901,7 +1901,7 @@ bool CSSParser::parseContent(int propId, bool important)
             // no-close-quote
             // FIXME: These are not yet implemented (http://bugs.webkit.org/show_bug.cgi?id=6503).
         } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
-            parsedValue = new CSSPrimitiveValue(val->string, CSSPrimitiveValue::CSS_STRING);
+            parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
         }
         if (!parsedValue)
             break;
@@ -1923,7 +1923,7 @@ PassRefPtr<CSSValue> CSSParser::parseBackgroundColor()
     int id = m_valueList->current()->id;
     if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu || id == CSSValueCurrentcolor ||
         (id >= CSSValueGrey && id < CSSValueWebkitText && !m_strict))
-       return new CSSPrimitiveValue(id);
+       return CSSPrimitiveValue::createIdentifier(id);
     return parseColor();
 }
 
@@ -1970,10 +1970,10 @@ PassRefPtr<CSSValue> CSSParser::parseFillPositionXY(bool& xFound, bool& yFound)
         else if (id == CSSValueCenter)
             // Center is ambiguous, so we're not sure which position we've found yet, an x or a y.
             percent = 50;
-        return new CSSPrimitiveValue(percent, CSSPrimitiveValue::CSS_PERCENTAGE);
+        return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::CSS_PERCENTAGE);
     }
     if (validUnit(m_valueList->current(), FPercent|FLength, m_strict))
-        return new CSSPrimitiveValue(m_valueList->current()->fValue,
+        return CSSPrimitiveValue::create(m_valueList->current()->fValue,
                                          (CSSPrimitiveValue::UnitTypes)m_valueList->current()->unit);
                 
     return 0;
@@ -2016,7 +2016,7 @@ void CSSParser::parseFillPosition(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& va
         // is simply 50%.  This is our default.
         // For keywords, the keyword was either an x-keyword (left/right), a y-keyword (top/bottom), or an ambiguous keyword (center).
         // For left/right/center, the default of 50% in the y is still correct.
-        value2 = new CSSPrimitiveValue(50, CSSPrimitiveValue::CSS_PERCENTAGE);
+        value2 = CSSPrimitiveValue::create(50, CSSPrimitiveValue::CSS_PERCENTAGE);
 
     if (value1IsY || value2IsX)
         value1.swap(value2);
@@ -2025,31 +2025,28 @@ void CSSParser::parseFillPosition(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& va
 PassRefPtr<CSSValue> CSSParser::parseFillSize()
 {
     Value* value = m_valueList->current();
-    CSSPrimitiveValue* parsedValue1;
+    RefPtr<CSSPrimitiveValue> parsedValue1;
     
     if (value->id == CSSValueAuto)
-        parsedValue1 = new CSSPrimitiveValue(0, CSSPrimitiveValue::CSS_UNKNOWN);
+        parsedValue1 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
     else {
         if (!validUnit(value, FLength|FPercent, m_strict))
             return 0;
-        parsedValue1 = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+        parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     }
     
-    CSSPrimitiveValue* parsedValue2 = parsedValue1;
+    RefPtr<CSSPrimitiveValue> parsedValue2 = parsedValue1;
     if ((value = m_valueList->next())) {
         if (value->id == CSSValueAuto)
-            parsedValue2 = new CSSPrimitiveValue(0, CSSPrimitiveValue::CSS_UNKNOWN);
+            parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
         else {
-            if (!validUnit(value, FLength|FPercent, m_strict)) {
-                delete parsedValue1;
+            if (!validUnit(value, FLength|FPercent, m_strict))
                 return 0;
-            }
-            parsedValue2 = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+            parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
         }
     }
     
-    RefPtr<Pair> pair = Pair::create(parsedValue1, parsedValue2);
-    return new CSSPrimitiveValue(pair.release());
+    return CSSPrimitiveValue::create(Pair::create(parsedValue1.release(), parsedValue2.release()));
 }
 
 bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2, 
@@ -2093,7 +2090,7 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
                 case CSSPropertyBackgroundAttachment:
                 case CSSPropertyWebkitMaskAttachment:
                     if (val->id == CSSValueScroll || val->id == CSSValueFixed) {
-                        currValue = new CSSPrimitiveValue(val->id);
+                        currValue = CSSPrimitiveValue::createIdentifier(val->id);
                         m_valueList->next();
                     }
                     break;
@@ -2107,7 +2104,7 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
                 case CSSPropertyWebkitMaskClip:
                 case CSSPropertyWebkitMaskOrigin:
                     if (val->id == CSSValueBorder || val->id == CSSValuePadding || val->id == CSSValueContent || val->id == CSSValueText) {
-                        currValue = new CSSPrimitiveValue(val->id);
+                        currValue = CSSPrimitiveValue::createIdentifier(val->id);
                         m_valueList->next();
                     }
                     break;
@@ -2135,14 +2132,14 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
                 case CSSPropertyWebkitBackgroundComposite:
                 case CSSPropertyWebkitMaskComposite:
                     if ((val->id >= CSSValueClear && val->id <= CSSValuePlusLighter) || val->id == CSSValueHighlight) {
-                        currValue = new CSSPrimitiveValue(val->id);
+                        currValue = CSSPrimitiveValue::createIdentifier(val->id);
                         m_valueList->next();
                     }
                     break;
                 case CSSPropertyBackgroundRepeat:
                 case CSSPropertyWebkitMaskRepeat:
                     if (val->id >= CSSValueRepeat && val->id <= CSSValueNoRepeat) {
-                        currValue = new CSSPrimitiveValue(val->id);
+                        currValue = CSSPrimitiveValue::createIdentifier(val->id);
                         m_valueList->next();
                     }
                     break;
@@ -2157,12 +2154,12 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
                 return false;
             
             if (value && !values) {
-                values = new CSSValueList();
+                values = CSSValueList::createCommaSeparated();
                 values->append(value.release());
             }
             
             if (value2 && !values2) {
-                values2 = new CSSValueList();
+                values2 = CSSValueList::createCommaSeparated();
                 values2->append(value2.release());
             }
             
@@ -2203,7 +2200,7 @@ PassRefPtr<CSSValue> CSSParser::parseTransitionDuration()
 {
     Value* value = m_valueList->current();
     if (validUnit(value, FTime, m_strict))
-        return new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+        return CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     return 0;
 }
 
@@ -2211,9 +2208,9 @@ PassRefPtr<CSSValue> CSSParser::parseTransitionRepeatCount()
 {
     Value* value = m_valueList->current();
     if (value->id == CSSValueInfinite)
-        return new CSSPrimitiveValue(value->id);
+        return CSSPrimitiveValue::createIdentifier(value->id);
     if (validUnit(value, FInteger|FNonNeg, m_strict))
-        return new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+        return CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     return 0;
 }
 
@@ -2239,7 +2236,7 @@ PassRefPtr<CSSValue> CSSParser::parseTransitionTimingFunction()
 {
     Value* value = m_valueList->current();
     if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut || value->id == CSSValueEaseInOut)
-        return new CSSPrimitiveValue(value->id);
+        return CSSPrimitiveValue::createIdentifier(value->id);
     
     // We must be a function.
     if (value->unit != Value::Function)
@@ -2262,7 +2259,7 @@ PassRefPtr<CSSValue> CSSParser::parseTransitionTimingFunction()
     if (!parseTimingFunctionValue(args, y2))
         return 0;
 
-    return new CSSTimingFunctionValue(x1, y1, x2, y2);
+    return CSSTimingFunctionValue::create(x1, y1, x2, y2);
 }
 
 PassRefPtr<CSSValue> CSSParser::parseTransitionProperty()
@@ -2272,11 +2269,11 @@ PassRefPtr<CSSValue> CSSParser::parseTransitionProperty()
         return 0;
     int result = cssPropertyID(value->string);
     if (result)
-        return new CSSPrimitiveValue(result);
+        return CSSPrimitiveValue::createIdentifier(result);
     if (equalIgnoringCase(value->string, "all"))
-        return new CSSPrimitiveValue(cAnimateAll);
+        return CSSPrimitiveValue::createIdentifier(cAnimateAll); // FIXME: Why not use CSSValueAll instead?
     if (equalIgnoringCase(value->string, "none"))
-        return new CSSPrimitiveValue(cAnimateNone);
+        return CSSPrimitiveValue::createIdentifier(cAnimateNone); // FIXME: Why not use CSSValueNone instead?
     return 0;
 }
 
@@ -2325,7 +2322,7 @@ bool CSSParser::parseTransitionProperty(int propId, RefPtr<CSSValue>& result)
                 return false;
             
             if (value && !values) {
-                values = new CSSValueList();
+                values = CSSValueList::createCommaSeparated();
                 values->append(value.release());
             }
             
@@ -2379,7 +2376,7 @@ bool CSSParser::parseDashboardRegions(int propId, bool important)
     if (value->id == CSSValueNone) {
         if (m_valueList->next())
             return false;
-        addProperty(propId, new CSSPrimitiveValue(value->id), important);
+        addProperty(propId, CSSPrimitiveValue::createIdentifier(value->id), important);
         return valid;
     }
         
@@ -2449,14 +2446,13 @@ bool CSSParser::parseDashboardRegions(int propId, bool important)
 
         if (numArgs == DASHBOARD_REGION_SHORT_NUM_PARAMETERS || numArgs == (DASHBOARD_REGION_SHORT_NUM_PARAMETERS*2-1)) {
             // This originally used CSSValueInvalid by accident. It might be more logical to use something else.
-            CSSPrimitiveValue *amount = new CSSPrimitiveValue(CSSValueInvalid);
+            RefPtr<CSSPrimitiveValue> amount = CSSPrimitiveValue::createIdentifier(CSSValueInvalid);
                 
             region->setTop(amount);
             region->setRight(amount);
             region->setBottom(amount);
             region->setLeft(amount);
-        }
-        else {
+        } else {
             // Next four arguments must be offset numbers
             int i;
             for (i = 0; i < 4; i++) {
@@ -2467,9 +2463,9 @@ bool CSSParser::parseDashboardRegions(int propId, bool important)
                 if (!valid)
                     break;
                     
-                CSSPrimitiveValue *amount = arg->id == CSSValueAuto ?
-                    new CSSPrimitiveValue(CSSValueAuto) :
-                    new CSSPrimitiveValue(arg->fValue, (CSSPrimitiveValue::UnitTypes) arg->unit);
+                RefPtr<CSSPrimitiveValue> amount = arg->id == CSSValueAuto ?
+                    CSSPrimitiveValue::createIdentifier(CSSValueAuto) :
+                    CSSPrimitiveValue::create(arg->fValue, (CSSPrimitiveValue::UnitTypes) arg->unit);
                     
                 if (i == 0)
                     region->setTop(amount);
@@ -2489,7 +2485,7 @@ bool CSSParser::parseDashboardRegions(int propId, bool important)
     }
 
     if (valid)
-        addProperty(propId, new CSSPrimitiveValue(firstRegion.release()), important);
+        addProperty(propId, CSSPrimitiveValue::create(firstRegion.release()), important);
         
     return valid;
 }
@@ -2505,11 +2501,11 @@ PassRefPtr<CSSValue> CSSParser::parseCounterContent(ValueList* args, bool counte
         return 0;
     
     Value* i = args->current();
-    RefPtr<CSSPrimitiveValue> identifier = new CSSPrimitiveValue(i->string, CSSPrimitiveValue::CSS_STRING);
+    RefPtr<CSSPrimitiveValue> identifier = CSSPrimitiveValue::create(i->string, CSSPrimitiveValue::CSS_STRING);
 
     RefPtr<CSSPrimitiveValue> separator;
     if (!counters)
-        separator = new CSSPrimitiveValue(String(), CSSPrimitiveValue::CSS_STRING);
+        separator = CSSPrimitiveValue::create(String(), CSSPrimitiveValue::CSS_STRING);
     else {
         i = args->next();
         if (i->unit != Value::Operator || i->iValue != ',')
@@ -2519,13 +2515,13 @@ PassRefPtr<CSSValue> CSSParser::parseCounterContent(ValueList* args, bool counte
         if (i->unit != CSSPrimitiveValue::CSS_STRING)
             return 0;
         
-        separator = new CSSPrimitiveValue(i->string, (CSSPrimitiveValue::UnitTypes) i->unit);
+        separator = CSSPrimitiveValue::create(i->string, (CSSPrimitiveValue::UnitTypes) i->unit);
     }
 
     RefPtr<CSSPrimitiveValue> listStyle;
     i = args->next();
     if (!i) // Make the list style default decimal
-        listStyle = new CSSPrimitiveValue(CSSValueDecimal - CSSValueDisc, CSSPrimitiveValue::CSS_NUMBER);
+        listStyle = CSSPrimitiveValue::create(CSSValueDecimal - CSSValueDisc, CSSPrimitiveValue::CSS_NUMBER);
     else {
         if (i->unit != Value::Operator || i->iValue != ',')
             return 0;
@@ -2542,10 +2538,10 @@ PassRefPtr<CSSValue> CSSParser::parseCounterContent(ValueList* args, bool counte
         else
             return 0;
 
-        listStyle = new CSSPrimitiveValue(ls, (CSSPrimitiveValue::UnitTypes) i->unit);
+        listStyle = CSSPrimitiveValue::create(ls, (CSSPrimitiveValue::UnitTypes) i->unit);
     }
 
-    return new CSSPrimitiveValue(Counter::create(identifier.release(), listStyle.release(), separator.release()));
+    return CSSPrimitiveValue::create(Counter::create(identifier.release(), listStyle.release(), separator.release()));
 }
 
 bool CSSParser::parseShape(int propId, bool important)
@@ -2566,9 +2562,9 @@ bool CSSParser::parseShape(int propId, bool important)
         valid = a->id == CSSValueAuto || validUnit(a, FLength, m_strict);
         if (!valid)
             break;
-        CSSPrimitiveValue *length = a->id == CSSValueAuto ?
-            new CSSPrimitiveValue(CSSValueAuto) :
-            new CSSPrimitiveValue(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
+        RefPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ?
+            CSSPrimitiveValue::createIdentifier(CSSValueAuto) :
+            CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit);
         if (i == 0)
             rect->setTop(length);
         else if (i == 1)
@@ -2589,7 +2585,7 @@ bool CSSParser::parseShape(int propId, bool important)
         i++;
     }
     if (valid) {
-        addProperty(propId, new CSSPrimitiveValue(rect.release()), important);
+        addProperty(propId, CSSPrimitiveValue::create(rect.release()), important);
         m_valueList->next();
         return true;
     }
@@ -2601,7 +2597,7 @@ bool CSSParser::parseFont(bool important)
 {
     bool valid = true;
     Value *value = m_valueList->current();
-    RefPtr<FontValue> font = new FontValue;
+    RefPtr<FontValue> font = FontValue::create();
     // optional font-style, font-variant and font-weight
     while (value) {
         int id = value->id;
@@ -2611,15 +2607,15 @@ bool CSSParser::parseFont(bool important)
             } else if (id == CSSValueItalic || id == CSSValueOblique) {
                 if (font->style)
                     return false;
-                font->style = new CSSPrimitiveValue(id);
+                font->style = CSSPrimitiveValue::createIdentifier(id);
             } else if (id == CSSValueSmallCaps) {
                 if (font->variant)
                     return false;
-                font->variant = new CSSPrimitiveValue(id);
+                font->variant = CSSPrimitiveValue::createIdentifier(id);
             } else if (id >= CSSValueBold && id <= CSSValueLighter) {
                 if (font->weight)
                     return false;
-                font->weight = new CSSPrimitiveValue(id);
+                font->weight = CSSPrimitiveValue::createIdentifier(id);
             } else {
                 valid = false;
             }
@@ -2646,7 +2642,7 @@ bool CSSParser::parseFont(bool important)
                 val = CSSValue900;
 
             if (val)
-                font->weight = new CSSPrimitiveValue(val);
+                font->weight = CSSPrimitiveValue::createIdentifier(val);
             else
                 valid = false;
         } else {
@@ -2661,18 +2657,18 @@ bool CSSParser::parseFont(bool important)
 
     // set undefined values to default
     if (!font->style)
-        font->style = new CSSPrimitiveValue(CSSValueNormal);
+        font->style = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     if (!font->variant)
-        font->variant = new CSSPrimitiveValue(CSSValueNormal);
+        font->variant = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     if (!font->weight)
-        font->weight = new CSSPrimitiveValue(CSSValueNormal);
+        font->weight = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
 
     // now a font size _must_ come
     // <absolute-size> | <relative-size> | <length> | <percentage> | inherit
     if (value->id >= CSSValueXxSmall && value->id <= CSSValueLarger)
-        font->size = new CSSPrimitiveValue(value->id);
+        font->size = CSSPrimitiveValue::createIdentifier(value->id);
     else if (validUnit(value, FLength|FPercent|FNonNeg, m_strict))
-        font->size = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
+        font->size = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     value = m_valueList->next();
     if (!font->size || !value)
         return false;
@@ -2685,7 +2681,7 @@ bool CSSParser::parseFont(bool important)
         if (value->id == CSSValueNormal) {
             // default value, nothing to do
         } else if (validUnit(value, FNumber|FLength|FPercent|FNonNeg, m_strict))
-            font->lineHeight = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
+            font->lineHeight = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
         else
             return false;
         value = m_valueList->next();
@@ -2694,7 +2690,7 @@ bool CSSParser::parseFont(bool important)
     }
     
     if (!font->lineHeight)
-        font->lineHeight = new CSSPrimitiveValue(CSSValueNormal);
+        font->lineHeight = CSSPrimitiveValue::createIdentifier(CSSValueNormal);
 
     // font family must come now
     font->family = parseFontFamily();
@@ -2708,7 +2704,7 @@ bool CSSParser::parseFont(bool important)
 
 PassRefPtr<CSSValueList> CSSParser::parseFontFamily()
 {
-    CSSValueList* list = new CSSValueList;
+    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     Value* value = m_valueList->current();
     FontFamilyValue* currFamily = 0;
     while (value) {
@@ -2723,24 +2719,27 @@ PassRefPtr<CSSValueList> CSSParser::parseFontFamily()
             if (currFamily)
                 currFamily->appendSpaceSeparated(value->string.characters, value->string.length);
             else if (nextValBreaksFont || !nextValIsFontName)
-                list->append(new CSSPrimitiveValue(value->id));
-            else
-                list->append(currFamily = new FontFamilyValue(value->string));
-        }
-        else if (value->unit == CSSPrimitiveValue::CSS_STRING) {
+                list->append(CSSPrimitiveValue::createIdentifier(value->id));
+            else {
+                RefPtr<FontFamilyValue> newFamily = FontFamilyValue::create(value->string);
+                currFamily = newFamily.get();
+                list->append(newFamily.release());
+            }
+        } else if (value->unit == CSSPrimitiveValue::CSS_STRING) {
             // Strings never share in a family name.
             currFamily = 0;
-            list->append(new FontFamilyValue(value->string));
-        }
-        else if (value->unit == CSSPrimitiveValue::CSS_IDENT) {
+            list->append(FontFamilyValue::create(value->string));
+        } else if (value->unit == CSSPrimitiveValue::CSS_IDENT) {
             if (currFamily)
                 currFamily->appendSpaceSeparated(value->string.characters, value->string.length);
             else if (nextValBreaksFont || !nextValIsFontName)
-                list->append(new FontFamilyValue(value->string));
-            else
-                list->append(currFamily = new FontFamilyValue(value->string));
-        }
-        else {
+                list->append(FontFamilyValue::create(value->string));
+            else {
+                RefPtr<FontFamilyValue> newFamily = FontFamilyValue::create(value->string);
+                currFamily = newFamily.get();
+                list->append(newFamily.release());
+            }
+        } else {
             break;
         }
         
@@ -2756,16 +2755,14 @@ PassRefPtr<CSSValueList> CSSParser::parseFontFamily()
         else
             break;
     }
-    if (!list->length()) {
-        delete list;
+    if (!list->length())
         list = 0;
-    }
-    return list;
+    return list.release();
 }
 
 bool CSSParser::parseFontFaceSrc()
 {
-    RefPtr<CSSValueList> values(new CSSValueList());
+    RefPtr<CSSValueList> values(CSSValueList::createCommaSeparated());
     Value* val;
     bool expectComma = false;
     bool allowFormat = false;
@@ -2775,7 +2772,7 @@ bool CSSParser::parseFontFaceSrc()
         RefPtr<CSSFontFaceSrcValue> parsedValue;
         if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma) {
             String value = parseURL(val->string);
-            parsedValue = new CSSFontFaceSrcValue(KURL(m_styleSheet->baseURL(), value).string(), false);
+            parsedValue = CSSFontFaceSrcValue::create(KURL(m_styleSheet->baseURL(), value).string());
             uriValue = parsedValue;
             allowFormat = true;
             expectComma = true;
@@ -2788,7 +2785,7 @@ bool CSSParser::parseFontFaceSrc()
                     allowFormat = false;
                     Value* a = args->current();
                     uriValue.clear();
-                    parsedValue = new CSSFontFaceSrcValue(a->string, true);
+                    parsedValue = CSSFontFaceSrcValue::createLocal(a->string);
                 } else if (equalIgnoringCase(val->function->name, "format(") && allowFormat && uriValue) {
                     expectComma = true;
                     allowFormat = false;
@@ -2826,7 +2823,7 @@ bool CSSParser::parseFontFaceSrc()
 
 bool CSSParser::parseFontFaceUnicodeRange()
 {
-    CSSValueList* values = new CSSValueList();
+    RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
     Value* currentValue;
     bool failed = false;
     while ((currentValue = m_valueList->current())) {
@@ -2902,14 +2899,12 @@ bool CSSParser::parseFontFaceUnicodeRange()
             if (failed)
                 break;
         }
-        values->append(new CSSUnicodeRangeValue(from, to));
+        values->append(CSSUnicodeRangeValue::create(from, to));
         m_valueList->next();
     }
-    if (failed || !values->length()) {
-        delete values;
+    if (failed || !values->length())
         return false;
-    }
-    addProperty(CSSPropertyUnicodeRange, values, m_important);
+    addProperty(CSSPropertyUnicodeRange, values.release(), m_important);
     return true;
 }
 
@@ -3003,7 +2998,7 @@ PassRefPtr<CSSPrimitiveValue> CSSParser::parseColor(Value* value)
     RGBA32 c = Color::transparent;
     if (!parseColorFromValue(value ? value : m_valueList->current(), c))
         return 0;
-    return new CSSPrimitiveValue(c);
+    return CSSPrimitiveValue::createColor(c);
 }
 
 bool CSSParser::parseColorFromValue(Value* value, RGBA32& c, bool svg)
@@ -3076,10 +3071,10 @@ struct ShadowParseContext {
         // Handle the ,, case gracefully by doing nothing.
         if (x || y || blur || color) {
             if (!values)
-                values = new CSSValueList();
+                values = CSSValueList::createCommaSeparated();
             
             // Construct the current shadow value and add it to the list.
-            values->append(new ShadowValue(x.release(), y.release(), blur.release(), color.release()));
+            values->append(ShadowValue::create(x.release(), y.release(), blur.release(), color.release()));
         }
         
         // Now reset for the next shadow value.
@@ -3089,7 +3084,7 @@ struct ShadowParseContext {
     }
 
     void commitLength(Value* v) {
-        RefPtr<CSSPrimitiveValue> val = new CSSPrimitiveValue(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
+        RefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
 
         if (allowX) {
             x = val.release();
@@ -3159,7 +3154,7 @@ bool CSSParser::parseShadow(int propId, bool important)
             if (isColor) {
                 if (!context.allowColor)
                     return false;
-                parsedColor = new CSSPrimitiveValue(val->id);
+                parsedColor = CSSPrimitiveValue::createIdentifier(val->id);
             }
 
             if (!parsedColor)
@@ -3216,11 +3211,11 @@ bool CSSParser::parseReflect(int propId, bool important)
     val = m_valueList->next();
     RefPtr<CSSPrimitiveValue> offset;
     if (!val)
-        offset = new CSSPrimitiveValue(0, CSSPrimitiveValue::CSS_PX);
+        offset = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
     else {
         if (!validUnit(val, FLength | FPercent, m_strict))
             return false;
-        offset = new CSSPrimitiveValue(val->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(val->unit));
+        offset = CSSPrimitiveValue::create(val->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(val->unit));
     }
 
     // Now for the mask.
@@ -3261,7 +3256,7 @@ struct BorderImageParseContext
 
     void commitImage(PassRefPtr<CSSValue> image) { m_image = image; m_allowNumber = true; }
     void commitNumber(Value* v) {
-        PassRefPtr<CSSPrimitiveValue> val = new CSSPrimitiveValue(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
+        PassRefPtr<CSSPrimitiveValue> val = CSSPrimitiveValue::create(v->fValue, (CSSPrimitiveValue::UnitTypes)v->unit);
         if (!m_top)
             m_top = val;
         else if (!m_right)
@@ -3302,16 +3297,16 @@ struct BorderImageParseContext
     PassRefPtr<CSSValue> commitBorderImage(CSSParser* p, bool important) {
         // We need to clone and repeat values for any omissions.
         if (!m_right) {
-            m_right = new CSSPrimitiveValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
-            m_bottom = new CSSPrimitiveValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
-            m_left = new CSSPrimitiveValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_right = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_bottom = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_left = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
         }
         if (!m_bottom) {
-            m_bottom = new CSSPrimitiveValue(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
-            m_left = new CSSPrimitiveValue(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
+            m_bottom = CSSPrimitiveValue::create(m_top->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_left = CSSPrimitiveValue::create(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
         }
         if (!m_left)
-             m_left = new CSSPrimitiveValue(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
+             m_left = CSSPrimitiveValue::create(m_right->getDoubleValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
              
         // Now build a rect value to hold all four of our primitive values.
         RefPtr<Rect> rect = Rect::create();
@@ -3345,7 +3340,7 @@ struct BorderImageParseContext
         }
 
         // Make our new border image value now.
-        return new CSSBorderImageValue(m_image, rect.release(), m_horizontalRule, m_verticalRule);
+        return CSSBorderImageValue::create(m_image, rect.release(), m_horizontalRule, m_verticalRule);
     }
     
     bool m_allowBreak;
@@ -3409,7 +3404,7 @@ bool CSSParser::parseBorderImage(int propId, bool important, RefPtr<CSSValue>& r
     
     if (context.allowNumber() && propId != CSSPropertyWebkitBorderImage) {
         // Allow the slices to be omitted for images that don't fit to a border.  We just set the slices to be 0.
-        context.m_top = new CSSPrimitiveValue(0, CSSPrimitiveValue::CSS_NUMBER);
+        context.m_top = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_NUMBER);
         context.m_allowBreak = true;
     }
 
@@ -3426,7 +3421,7 @@ bool CSSParser::parseCounter(int propId, int defaultValue, bool important)
 {
     enum { ID, VAL } state = ID;
 
-    RefPtr<CSSValueList> list = new CSSValueList;
+    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     RefPtr<CSSPrimitiveValue> counterName;
     
     while (true) {
@@ -3434,7 +3429,7 @@ bool CSSParser::parseCounter(int propId, int defaultValue, bool important)
         switch (state) {
             case ID:
                 if (val && val->unit == CSSPrimitiveValue::CSS_IDENT) {
-                    counterName = new CSSPrimitiveValue(val->string, CSSPrimitiveValue::CSS_STRING);
+                    counterName = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
                     state = VAL;
                     m_valueList->next();
                     continue;
@@ -3447,8 +3442,8 @@ bool CSSParser::parseCounter(int propId, int defaultValue, bool important)
                     m_valueList->next();
                 }
 
-                list->append(new CSSPrimitiveValue(Pair::create(counterName.release(),
-                    new CSSPrimitiveValue(i, CSSPrimitiveValue::CSS_NUMBER))));
+                list->append(CSSPrimitiveValue::create(Pair::create(counterName.release(),
+                    CSSPrimitiveValue::create(i, CSSPrimitiveValue::CSS_NUMBER))));
                 state = ID;
                 continue;
             }
@@ -3470,14 +3465,14 @@ static PassRefPtr<CSSPrimitiveValue> parseGradientPoint(Value* a, bool horizonta
     if (a->unit == CSSPrimitiveValue::CSS_IDENT) {
         if ((equalIgnoringCase(a->string, "left") && horizontal) || 
             (equalIgnoringCase(a->string, "top") && !horizontal))
-            result = new CSSPrimitiveValue(0., CSSPrimitiveValue::CSS_PERCENTAGE);
+            result = CSSPrimitiveValue::create(0., CSSPrimitiveValue::CSS_PERCENTAGE);
         else if ((equalIgnoringCase(a->string, "right") && horizontal) ||
                  (equalIgnoringCase(a->string, "bottom") && !horizontal))
-            result = new CSSPrimitiveValue(100., CSSPrimitiveValue::CSS_PERCENTAGE);
+            result = CSSPrimitiveValue::create(100., CSSPrimitiveValue::CSS_PERCENTAGE);
         else if (equalIgnoringCase(a->string, "center"))
-            result = new CSSPrimitiveValue(50., CSSPrimitiveValue::CSS_PERCENTAGE);
+            result = CSSPrimitiveValue::create(50., CSSPrimitiveValue::CSS_PERCENTAGE);
     } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
-        result = new CSSPrimitiveValue(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit);
+        result = CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes)a->unit);
     return result;
 }
 
@@ -3508,7 +3503,7 @@ bool parseGradientColorStop(CSSParser* p, Value* a, CSSGradientColorStop& stop)
         
         int id = args->current()->id;
         if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu)
-            stop.m_color =new CSSPrimitiveValue(id);
+            stop.m_color = CSSPrimitiveValue::createIdentifier(id);
         else
             stop.m_color = p->parseColor(args->current());
         if (!stop.m_color)
@@ -3535,7 +3530,7 @@ bool parseGradientColorStop(CSSParser* p, Value* a, CSSGradientColorStop& stop)
         stopArg = args->next();
         int id = stopArg->id;
         if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu)
-            stop.m_color =new CSSPrimitiveValue(id);
+            stop.m_color = CSSPrimitiveValue::createIdentifier(id);
         else
             stop.m_color = p->parseColor(stopArg);
         if (!stop.m_color)
@@ -3547,7 +3542,7 @@ bool parseGradientColorStop(CSSParser* p, Value* a, CSSGradientColorStop& stop)
 
 bool CSSParser::parseGradient(RefPtr<CSSValue>& gradient)
 {
-    RefPtr<CSSGradientValue> result = new CSSGradientValue;
+    RefPtr<CSSGradientValue> result = CSSGradientValue::create();
     
     // Walk the arguments.
     ValueList* args = m_valueList->current()->function->args;
@@ -3600,7 +3595,7 @@ bool CSSParser::parseGradient(RefPtr<CSSValue>& gradient)
         a = args->next();
         if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
             return false;
-        result->setFirstRadius(new CSSPrimitiveValue(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
+        result->setFirstRadius(CSSPrimitiveValue::create(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
         
         // Comma after the first radius.
         a = args->next();
@@ -3637,7 +3632,7 @@ bool CSSParser::parseGradient(RefPtr<CSSValue>& gradient)
         a = args->next();
         if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
             return false;
-        result->setSecondRadius(new CSSPrimitiveValue(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
+        result->setSecondRadius(CSSPrimitiveValue::create(a->fValue, CSSPrimitiveValue::CSS_NUMBER));
     }
 
     // We now will accept any number of stops (0 or more).
@@ -3668,7 +3663,7 @@ bool CSSParser::parseGradient(RefPtr<CSSValue>& gradient)
 
 bool CSSParser::parseCanvas(RefPtr<CSSValue>& canvas)
 {
-    RefPtr<CSSCanvasValue> result = new CSSCanvasValue;
+    RefPtr<CSSCanvasValue> result = CSSCanvasValue::create();
     
     // Walk the arguments.
     ValueList* args = m_valueList->current()->function->args;
@@ -3750,9 +3745,9 @@ PassRefPtr<CSSValueList> CSSParser::parseTransform()
     if (!m_valueList)
         return 0;
 
-    // The transform is a list of functional primitives that specify transform operations.  We collect a list
-    // of CSSTransformValues, where each value specifies a single operation.
-    RefPtr<CSSValueList> list = new CSSValueList;
+    // The transform is a list of functional primitives that specify transform operations.
+    // We collect a list of CSSTransformValues, where each value specifies a single operation.
+    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     for (Value* value = m_valueList->current(); value; value = m_valueList->next()) {
         if (value->unit != Value::Function || !value->function)
             return 0;
@@ -3771,7 +3766,7 @@ PassRefPtr<CSSValueList> CSSParser::parseTransform()
             return 0;
 
         // Create the new CSSTransformValue for this operation and add it to our list.
-        CSSTransformValue* transformValue = new CSSTransformValue(info.type());
+        RefPtr<CSSTransformValue> transformValue = CSSTransformValue::create(info.type());
         list->append(transformValue);
 
         // Snag our values.
@@ -3784,7 +3779,7 @@ PassRefPtr<CSSValueList> CSSParser::parseTransform()
                 return 0;
             
             // Add the value to the current transform operation.
-            transformValue->addValue(new CSSPrimitiveValue(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit));
+            transformValue->addValue(CSSPrimitiveValue::create(a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit));
 
             a = args->next();
             if (!a)
@@ -4164,36 +4159,40 @@ MediaQuery* CSSParser::sinkFloatingMediaQuery(MediaQuery* mq)
 
 MediaList* CSSParser::createMediaList()
 {
-    MediaList* list = new MediaList;
-    m_parsedStyleObjects.append(list);
-    return list;
+    RefPtr<MediaList> list = MediaList::create();
+    MediaList* result = list.get();
+    m_parsedStyleObjects.append(list.release());
+    return result;
 }
 
 CSSRule* CSSParser::createCharsetRule(const ParseString& charset)
 {
     if (!m_styleSheet)
         return 0;
-    CSSCharsetRule* rule = new CSSCharsetRule(m_styleSheet, charset);
-    m_parsedStyleObjects.append(rule);
-    return rule;
+    RefPtr<CSSCharsetRule> rule = CSSCharsetRule::create(m_styleSheet, charset);
+    CSSCharsetRule* result = rule.get();
+    m_parsedStyleObjects.append(rule.release());
+    return result;
 }
 
 CSSRule* CSSParser::createImportRule(const ParseString& url, MediaList* media)
 {
     if (!media || !m_styleSheet)
         return 0;
-    CSSImportRule* rule = new CSSImportRule(m_styleSheet, url, media);
-    m_parsedStyleObjects.append(rule);
-    return rule;
+    RefPtr<CSSImportRule> rule = CSSImportRule::create(m_styleSheet, url, media);
+    CSSImportRule* result = rule.get();
+    m_parsedStyleObjects.append(rule.release());
+    return result;
 }
 
 CSSRule* CSSParser::createMediaRule(MediaList* media, CSSRuleList* rules)
 {
     if (!media || !rules || !m_styleSheet)
         return 0;
-    CSSMediaRule* rule = new CSSMediaRule(m_styleSheet, media, rules);
-    m_parsedStyleObjects.append(rule);
-    return rule;
+    RefPtr<CSSMediaRule> rule = CSSMediaRule::create(m_styleSheet, media, rules);
+    CSSMediaRule* result = rule.get();
+    m_parsedStyleObjects.append(rule.release());
+    return result;
 }
 
 CSSRuleList* CSSParser::createRuleList()
@@ -4207,24 +4206,26 @@ CSSRuleList* CSSParser::createRuleList()
 
 CSSRule* CSSParser::createStyleRule(CSSSelector* selector)
 {
-    CSSStyleRule* rule = 0;
+    CSSStyleRule* result = 0;
     if (selector) {
-        rule = new CSSStyleRule(m_styleSheet);
-        m_parsedStyleObjects.append(rule);
+        RefPtr<CSSStyleRule> rule = CSSStyleRule::create(m_styleSheet);
         rule->setSelector(sinkFloatingSelector(selector));
-        rule->setDeclaration(new CSSMutableStyleDeclaration(rule, m_parsedProperties, m_numParsedProperties));
+        rule->setDeclaration(CSSMutableStyleDeclaration::create(rule.get(), m_parsedProperties, m_numParsedProperties));
+        result = rule.get();
+        m_parsedStyleObjects.append(rule.release());
     }
     clearProperties();
-    return rule;
+    return result;
 }
 
 CSSRule* CSSParser::createFontFaceRule()
 {
-    CSSFontFaceRule* rule = new CSSFontFaceRule(m_styleSheet);
-    m_parsedStyleObjects.append(rule);
-    rule->setDeclaration(new CSSMutableStyleDeclaration(rule, m_parsedProperties, m_numParsedProperties));
+    RefPtr<CSSFontFaceRule> rule = CSSFontFaceRule::create(m_styleSheet);
+    rule->setDeclaration(CSSMutableStyleDeclaration::create(rule.get(), m_parsedProperties, m_numParsedProperties));
     clearProperties();
-    return rule;
+    CSSFontFaceRule* result = rule.get();
+    m_parsedStyleObjects.append(rule.release());
+    return result;
 }
 
 static int cssPropertyID(const UChar* propertyName, unsigned length)
index 65b4f576a2356a2f7e5a904c449fe18323bc27b7..9e4b0106a6598f80979b7072e4288ba5aae8c54a 100644 (file)
@@ -29,13 +29,12 @@ namespace WebCore {
 
 class Counter;
 class DashboardRegion;
-struct Length;
 class Pair;
 class Rect;
 class RenderStyle;
 class StringImpl;
 
-typedef int ExceptionCode;
+struct Length;
 
 class CSSPrimitiveValue : public CSSValue {
 public:
@@ -67,20 +66,30 @@ public:
         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!
+        CSS_DASHBOARD_REGION = 101, // FIXME: Dashboard region should not be a primitive value.
         CSS_UNICODE_RANGE = 102
     };
 
-    // FIXME: int vs. unsigned overloading is too tricky for color vs. ident
-    CSSPrimitiveValue();
-    CSSPrimitiveValue(int ident);
-    CSSPrimitiveValue(double, UnitTypes);
-    CSSPrimitiveValue(const String&, UnitTypes);
-    CSSPrimitiveValue(unsigned color); // RGB value
-    CSSPrimitiveValue(const Length&);
-    template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMappings.h
-    template<typename T> CSSPrimitiveValue(T* val) { init(PassRefPtr<T>(val)); }
-    template<typename T> CSSPrimitiveValue(PassRefPtr<T> val) { init(val); }
+    static PassRefPtr<CSSPrimitiveValue> createIdentifier(int ident)
+    {
+        return adoptRef(new CSSPrimitiveValue(ident));
+    }
+    static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue)
+    {
+        return adoptRef(new CSSPrimitiveValue(rgbValue));
+    }
+    template<typename T> static PassRefPtr<CSSPrimitiveValue> create(T value)
+    {
+        return adoptRef(new CSSPrimitiveValue(value));
+    }
+    static PassRefPtr<CSSPrimitiveValue> create(double value, UnitTypes type)
+    {
+        return adoptRef(new CSSPrimitiveValue(value, type));
+    }
+    static PassRefPtr<CSSPrimitiveValue> create(const String& value, UnitTypes type)
+    {
+        return adoptRef(new CSSPrimitiveValue(value, type));
+    }
 
     virtual ~CSSPrimitiveValue();
 
@@ -108,9 +117,6 @@ public:
     float computeLengthFloat(RenderStyle*, double multiplier, bool computingFontSize = false);
     double computeLengthDouble(RenderStyle*, double multiplier = 1.0, bool computingFontSize = false);
 
-    // use with care!!!
-    void setPrimitiveType(unsigned short type) { m_type = type; }
-
     double getDoubleValue(unsigned short unitType, ExceptionCode&);
     double getDoubleValue(unsigned short unitType);
     double getDoubleValue() const { return m_value.num; }
@@ -142,10 +148,6 @@ public:
 
     DashboardRegion* getDashboardRegionValue() const { return m_type != CSS_DASHBOARD_REGION ? 0 : m_value.region; }
 
-    virtual bool isPrimitiveValue() const { return true; }
-
-    virtual unsigned short cssValueType() const;
-
     int getIdent();
     template<typename T> operator T() const; // Defined in CSSPrimitiveValueMappings.h
 
@@ -155,6 +157,33 @@ public:
     virtual bool isQuirkValue() { return false; }
 
 protected:
+    // FIXME: int vs. unsigned overloading is too subtle to distinguish the color and identifier cases.
+    CSSPrimitiveValue(int ident);
+    CSSPrimitiveValue(double, UnitTypes);
+    CSSPrimitiveValue(const String&, UnitTypes);
+
+private:
+    CSSPrimitiveValue();
+    CSSPrimitiveValue(unsigned color); // RGB value
+    CSSPrimitiveValue(const Length&);
+
+    template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMappings.h
+    template<typename T> CSSPrimitiveValue(T* val) { init(PassRefPtr<T>(val)); }
+    template<typename T> CSSPrimitiveValue(PassRefPtr<T> val) { init(val); }
+
+    static void create(int); // compile-time guard
+    static void create(unsigned); // compile-time guard
+    template<typename T> operator T*(); // compile-time guard
+
+    void init(PassRefPtr<Counter>);
+    void init(PassRefPtr<Rect>);
+    void init(PassRefPtr<Pair>);
+    void init(PassRefPtr<DashboardRegion>); // FIXME: Dashboard region should not be a primitive value.
+
+    virtual bool isPrimitiveValue() const { return true; }
+
+    virtual unsigned short cssValueType() const;
+
     int m_type;
     union {
         int ident;
@@ -166,14 +195,6 @@ protected:
         Pair* pair;
         DashboardRegion* region;
     } m_value;
-
-private:
-    template<typename T> operator T*(); // compile-time guard
-
-    void init(PassRefPtr<Counter>);
-    void init(PassRefPtr<Rect>);
-    void init(PassRefPtr<Pair>);
-    void init(PassRefPtr<DashboardRegion>); // FIXME: Why is dashboard region a primitive value? This makes no sense.
 };
 
 } // namespace WebCore
index 3655ca5117256ba03ec94a64fc3cb0cd898b693b..56857b7226cc3677f903e7423bd557735a0a74a2 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 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.
+// The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em.
+// 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:
+    static PassRefPtr<CSSQuirkPrimitiveValue> create(double value, UnitTypes type)
+    {
+        return adoptRef(new CSSQuirkPrimitiveValue(value, type));
+    }
+
+private:
     CSSQuirkPrimitiveValue(double num, UnitTypes type)
         : CSSPrimitiveValue(num, type)
     {
index 984f75020d2a5f86a55dacda9a599179fe7b149f..08649b7ca5a742692a97d9ee07e6d8d0c66e334b 100644 (file)
@@ -40,7 +40,7 @@ public:
     static PassRefPtr<CSSReflectValue> create(CSSReflectionDirection direction,
         PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
     {
-        return new CSSReflectValue(direction, offset, mask);
+        return adoptRef(new CSSReflectValue(direction, offset, mask));
     }
 
     CSSReflectionDirection direction() const { return m_direction; }
index 74cc7d31beee3510baa92a75d15b93e22ac88520..df0897833abcfecbeafaab01aa515e5488d3308f 100644 (file)
@@ -1,6 +1,4 @@
-/**
- * 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, 2007 Apple Inc. All rights reserved.
@@ -25,6 +23,7 @@
 #include "CSSRule.h"
 
 #include "CSSStyleSheet.h"
+#include "NotImplemented.h"
 
 namespace WebCore {
 
@@ -35,18 +34,14 @@ CSSStyleSheet* CSSRule::parentStyleSheet() const
 
 CSSRule* CSSRule::parentRule() const
 {
+    // FIXME: I believe this always returns 0.
+    // A correct implementation would have to look farther up than just the parent.
     return (parent() && parent()->isRule()) ? static_cast<CSSRule*>(parent()) : 0;
 }
 
-String CSSRule::cssText() const
-{
-    // FIXME: Implement!
-    return String();
-}
-
 void CSSRule::setCssText(const String& /*cssText*/, ExceptionCode& /*ec*/)
 {
-    // FIXME: Implement!
+    notImplemented();
 }
 
 } // namespace WebCore
index dfe57fc16cbce7c66d66aeb160c059f9e5717a03..3e3dbc2c7e586874941f8c34c978ac253d93a8a7 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * 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, 2007 Apple Inc. All rights reserved.
 #ifndef CSSRule_h
 #define CSSRule_h
 
-#include "StyleBase.h"
+#include "CSSStyleSheet.h"
 
 namespace WebCore {
 
-class CSSStyleSheet;
-
 typedef int ExceptionCode;
 
 class CSSRule : public StyleBase {
 public:
+    // FIXME: Change name to Type.
     enum CSSRuleType {
         UNKNOWN_RULE,
         STYLE_RULE,
@@ -44,20 +41,23 @@ public:
         PAGE_RULE
     };
 
-    CSSRule(StyleBase* parent)
-        : StyleBase(parent)
-    {
-    }
-
-    virtual bool isRule() { return true; }
-
+    // FIXME: Change to return CSSRuleType.
     virtual unsigned short type() const = 0;
 
     CSSStyleSheet* parentStyleSheet() const;
     CSSRule* parentRule() const;
 
-    virtual String cssText() const;
+    virtual String cssText() const = 0;
     void setCssText(const String&, ExceptionCode&);
+
+protected:
+    CSSRule(CSSStyleSheet* parent)
+        : StyleBase(parent)
+    {
+    }
+
+private:
+    virtual bool isRule() { return true; }
 };
 
 } // namespace WebCore
index 4e1fb68b1ebb29848c08db517b7e0bd812b5e66f..ae0e124590873ecc29e31b918fdaf7f5f446df85 100644 (file)
@@ -38,11 +38,6 @@ CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parent)
 {
 }
 
-bool CSSStyleDeclaration::isStyleDeclaration()
-{
-    return true;
-}
-
 PassRefPtr<CSSValue> CSSStyleDeclaration::getPropertyCSSValue(const String& propertyName)
 {
     int propID = cssPropertyID(propertyName);
@@ -150,7 +145,7 @@ PassRefPtr<CSSMutableStyleDeclaration> CSSStyleDeclaration::copyPropertiesInSet(
         if (value)
             list.append(CSSProperty(set[i], value.release(), false));
     }
-    return new CSSMutableStyleDeclaration(0, list);
+    return CSSMutableStyleDeclaration::create(list);
 }
 
 } // namespace WebCore
index 2153c670926371f0a34219801c20eff8dd99f12f..e6fede631059ae7e9f74762e3d8c703e13292e20 100644 (file)
@@ -34,8 +34,6 @@ typedef int ExceptionCode;
 
 class CSSStyleDeclaration : public StyleBase {
 public:
-    virtual bool isStyleDeclaration();
-
     static bool isPropertyName(const String&);
 
     CSSRule* parentRule() const;
index 913c18fb6b466c1f3fb4c87a35e1d8f7350cf2bc..4f087591aaef9d9639ab229db6781998be172179 100644 (file)
@@ -1,9 +1,7 @@
-/**
- * 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.
+ * Copyright (C) 2002, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -29,7 +27,7 @@
 
 namespace WebCore {
 
-CSSStyleRule::CSSStyleRule(StyleBase* parent)
+CSSStyleRule::CSSStyleRule(CSSStyleSheet* parent)
     : CSSRule(parent)
     , m_selector(0)
 {
index f5dd92835399a23b8799e27b7f15d9c729fdd457..df63e064e2acb629ff0df4d83b4447f1e07a0df5 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * 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.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -33,23 +31,19 @@ namespace WebCore {
 class CSSMutableStyleDeclaration;
 class CSSSelector;
 
-typedef int ExceptionCode;
-
 class CSSStyleRule : public CSSRule {
 public:
-    CSSStyleRule(StyleBase* parent);
+    static PassRefPtr<CSSStyleRule> create(CSSStyleSheet* parent)
+    {
+        return adoptRef(new CSSStyleRule(parent));
+    }
     virtual ~CSSStyleRule();
 
-    virtual bool isStyleRule() { return true; }
-
     String selectorText() const;
     void setSelectorText(const String&, ExceptionCode&);
 
     CSSMutableStyleDeclaration* style() const { return m_style.get(); }
 
-    // Inherited from CSSRule
-    virtual unsigned short type() const { return STYLE_RULE; }
-
     virtual String cssText() const;
 
     // Not part of the CSSOM
@@ -61,7 +55,14 @@ public:
     CSSSelector* selector() { return m_selector; }
     CSSMutableStyleDeclaration* declaration() { return m_style.get(); }
  
-protected:
+private:
+    CSSStyleRule(CSSStyleSheet* parent);
+
+    virtual bool isStyleRule() { return true; }
+
+    // Inherited from CSSRule
+    virtual unsigned short type() const { return STYLE_RULE; }
+
     RefPtr<CSSMutableStyleDeclaration> m_style;
     CSSSelector* m_selector;
 };
index fdbf223f6f2d91f61066b77802142b21b27e1861..614adb009592e32e611a04920b01555501a9ac07 100644 (file)
@@ -41,6 +41,7 @@
 #include "CSSStyleRule.h"
 #include "CSSStyleSheet.h"
 #include "CSSTimingFunctionValue.h"
+#include "CSSTransformValue.h"
 #include "CSSValueList.h"
 #include "CachedImage.h"
 #include "Counter.h"
@@ -348,7 +349,7 @@ CSSStyleSelector::CSSStyleSelector(Document* doc, const String& userStyleSheet,
 
     // FIXME: This sucks! The user sheet is reparsed every time!
     if (!userStyleSheet.isEmpty()) {
-        m_userSheet = new CSSStyleSheet(doc);
+        m_userSheet = CSSStyleSheet::create(doc);
         m_userSheet->parseString(userStyleSheet, strictParsing);
 
         m_userStyle = new CSSRuleSet();
@@ -390,9 +391,7 @@ CSSStyleSelector::~CSSStyleSelector()
 
 static CSSStyleSheet* parseUASheet(const char* characters, unsigned size)
 {
-    CSSStyleSheet* const parent = 0;
-    CSSStyleSheet* sheet = new CSSStyleSheet(parent);
-    sheet->ref(); // leak the sheet on purpose
+    CSSStyleSheet* sheet = CSSStyleSheet::create().releaseRef(); // leak the sheet on purpose
     sheet->parseString(String(characters, size));
     return sheet;
 }
@@ -2175,7 +2174,7 @@ void CSSRuleSet::addRule(CSSStyleRule* rule, CSSSelector* sel)
 
 void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluator& medium, CSSStyleSelector* styleSelector)
 {
-    if (!sheet || !sheet->isCSSStyleSheet())
+    if (!sheet)
         return;
 
     // No media implies "all", but if a media list exists it must
@@ -4477,8 +4476,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                     result *= 3;
                 else if (primitiveValue->getIdent() == CSSValueThick)
                     result *= 5;
-                CSSPrimitiveValue val(result, CSSPrimitiveValue::CSS_EMS);
-                width = val.computeLengthFloat(m_style, zoomFactor);
+                width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLengthFloat(m_style, zoomFactor);
                 break;
             }
             default:
index 863e2fb4c0d5a8fd3e3e913f824b5d76df7afc2b..74947a259e2ff11428c93ed6476acbe8edbd5d1f 100644 (file)
@@ -176,7 +176,7 @@ void CSSStyleSheet::checkLoaded()
         return;
     if (parent())
         parent()->checkLoaded();
-    m_loadCompleted = m_parentNode ? m_parentNode->sheetLoaded() : true;
+    m_loadCompleted = ownerNode() ? ownerNode()->sheetLoaded() : true;
 }
 
 DocLoader *CSSStyleSheet::docLoader()
index b375eca5da7923776bfc909fda960f6792c0279b..eae245ed1218119d10d857092e69498bfe53e2fa 100644 (file)
@@ -36,16 +36,29 @@ typedef int ExceptionCode;
 
 class CSSStyleSheet : public StyleSheet {
 public:
-    CSSStyleSheet(Node* parentNode, const String& href = String(), const String& charset = String());
-    CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href = String(), const String& charset = String());
-    CSSStyleSheet(CSSRule* ownerRule, const String& href = String(), const String& charset = String());
+    static PassRefPtr<CSSStyleSheet> create()
+    {
+        return adoptRef(new CSSStyleSheet(static_cast<CSSStyleSheet*>(0), String(), String()));
+    }
+    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode)
+    {
+        return adoptRef(new CSSStyleSheet(ownerNode, String(), String()));
+    }
+    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href)
+    {
+        return adoptRef(new CSSStyleSheet(ownerNode, href, String()));
+    }
+    static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href, const String& charset)
+    {
+        return adoptRef(new CSSStyleSheet(ownerNode, href, charset));
+    }
+    static PassRefPtr<CSSStyleSheet> create(CSSRule* ownerRule, const String& href, const String& charset)
+    {
+        return adoptRef(new CSSStyleSheet(ownerRule, href, charset));
+    }
+
+    virtual ~CSSStyleSheet();
     
-    ~CSSStyleSheet();
-    
-    virtual bool isCSSStyleSheet() const { return true; }
-
-    virtual String type() const { return "text/css"; }
-
     CSSRule* ownerRule() const;
     PassRefPtr<CSSRuleList> cssRules(bool omitCharsetRules = false);
     unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
@@ -75,7 +88,14 @@ public:
     
     virtual void addSubresourceURLStrings(HashSet<String>&, const String& baseURL) const;
 
-protected:
+private:
+    CSSStyleSheet(Node* ownerNode, const String& href, const String& charset);
+    CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset);
+    CSSStyleSheet(CSSRule* ownerRule, const String& href, const String& charset);
+    
+    virtual bool isCSSStyleSheet() const { return true; }
+    virtual String type() const { return "text/css"; }
+
     Document* m_doc;
     CSSNamespace* m_namespaces;
     String m_charset;
index 5d808beffc9466a5e7af205915e819d20799e63f..3cb3ebda0459e056a87e01f5667486f12daa5990 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
+
 #ifndef CSSTimingFunctionValue_h
 #define CSSTimingFunctionValue_h
 
 #include "CSSValue.h"
-#include "FloatPoint.h"
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
-class CSSTimingFunctionValue : public CSSValue
-{
+class CSSTimingFunctionValue : public CSSValue {
 public:
-    CSSTimingFunctionValue(double x1, double y1, double x2, double y2)
-    : m_x1(x1)
-    , m_y1(y1)
-    , m_x2(x2)
-    , m_y2(y2)
+    static PassRefPtr<CSSTimingFunctionValue> create(double x1, double y1, double x2, double y2)
     {
+        return adoptRef(new CSSTimingFunctionValue(x1, y1, x2, y2));
     }
 
     virtual String cssText() const;
 
-    virtual bool isTransitionTimingFunctionValue() { return true; }
-    
     double x1() const { return m_x1; }
     double y1() const { return m_y1; }
     double x2() const { return m_x2; }
     double y2() const { return m_y2; }
 
 private:
+    CSSTimingFunctionValue(double x1, double y1, double x2, double y2)
+        : m_x1(x1)
+        , m_y1(y1)
+        , m_x2(x2)
+        , m_y2(y2)
+    {
+    }
+
+    virtual bool isTransitionTimingFunctionValue() { return true; }
+    
     double m_x1;
     double m_y1;
     double m_x2;
index 34f4dae42118d2130ed0bf7ad113c290825c53cf..f4467090c432339fcfda6b3280d9f3a3de68572a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #include "config.h"
 #include "CSSTransformValue.h"
+
+#include "CSSValueList.h"
 #include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
 CSSTransformValue::CSSTransformValue(TransformOperationType op)
-: m_type(op)
-{}
+    : m_type(op)
+{
+}
 
 CSSTransformValue::~CSSTransformValue()
-{}
+{
+}
 
-void CSSTransformValue::addValue(CSSValue* val)
+void CSSTransformValue::addValue(PassRefPtr<CSSValue> val)
 {
     if (!m_values)
-        m_values = new CSSValueList;
+        m_values = CSSValueList::createCommaSeparated();
     m_values->append(val);
 }
 
 String CSSTransformValue::cssText() const
 {
     String result;
-    switch(m_type) {
+    switch (m_type) {
         case ScaleTransformOperation:
             result += "scale(";
             break;
index 6a35d39290c618946ef1c187d3daf51dd554a6c8..f18bd3dc6e2cd0c3d50e09a6515bb5d8eb2eb4b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "CSSValue.h"
-#include "CSSValueList.h"
+#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-class CSSTransformValue : public CSSValue
-{
+class CSSValueList;
+
+class CSSTransformValue : public CSSValue {
 public:
     enum TransformOperationType {
         UnknownTransformOperation,
@@ -47,17 +48,23 @@ public:
         MatrixTransformOperation
     };
 
-    CSSTransformValue(TransformOperationType);
+    static PassRefPtr<CSSTransformValue> create(TransformOperationType type)
+    {
+        return adoptRef(new CSSTransformValue(type));
+    }
+
     virtual ~CSSTransformValue();
 
-    void addValue(CSSValue*);
+    void addValue(PassRefPtr<CSSValue>);
     
     virtual String cssText() const;
  
     TransformOperationType type() const { return m_type; }
     CSSValueList* values() const { return m_values.get(); }
     
-protected:
+private:
+    CSSTransformValue(TransformOperationType);
+
     TransformOperationType m_type;
     RefPtr<CSSValueList> m_values;
 };
index 8eca31ea7d463422ba95757367e49740f272207d..0ba1980eaeec7378b065e40214016a1b2e7d6654 100644 (file)
 #define CSSUnicodeRangeValue_h
 
 #include "CSSValue.h"
+#include <wtf/PassRefPtr.h>
 #include <wtf/unicode/Unicode.h>
 
 namespace WebCore {
 
 class CSSUnicodeRangeValue : public CSSValue {
 public:
-    CSSUnicodeRangeValue(UChar32 from, UChar32 to)
-        : m_from(from)
-        , m_to(to)
+    static PassRefPtr<CSSUnicodeRangeValue> create(UChar32 from, UChar32 to)
     {
+        return adoptRef(new CSSUnicodeRangeValue(from, to));
     }
 
     virtual ~CSSUnicodeRangeValue();
@@ -47,6 +47,12 @@ public:
     virtual String cssText() const;
 
 private:
+    CSSUnicodeRangeValue(UChar32 from, UChar32 to)
+        : m_from(from)
+        , m_to(to)
+    {
+    }
+
     UChar32 m_from;
     UChar32 m_to;
 };
index 4396eb74faa66470e7bd0740d05df1df585db1f8..b2448ddac73e4b0caac23a2ab688467726841986 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * 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.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 namespace WebCore {
 
 class CSSUnknownRule : public CSSRule {
-public:
-    CSSUnknownRule(StyleBase* parent)
-        : CSSRule(parent)
-    {
-    }
-
-    virtual bool isUnknownRule() { return true; }
-
+private:
     virtual unsigned short type() const { return UNKNOWN_RULE; }
 };
 
index dc5d8c285fbd2d47c8ea813c74c68d234fbc30ec..f891845c502cb3bb580c187eadec12431d61ee04 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -29,6 +29,7 @@ typedef int ExceptionCode;
 
 class CSSValue : public StyleBase {
 public:
+    // FIXME: Change name to Type.
     enum UnitTypes {
         CSS_INHERIT = 0,
         CSS_PRIMITIVE_VALUE = 1,
@@ -37,19 +38,27 @@ public:
         CSS_INITIAL = 4
     };
 
-    CSSValue() : StyleBase(0) { }
-
+    // FIXME: Change this to return UnitTypes.
     virtual unsigned short cssValueType() const { return CSS_CUSTOM; }
 
     virtual String cssText() const = 0;
     void setCssText(const String&, ExceptionCode&) { } // FIXME: Not implemented.
 
-    virtual bool isValue() { return true; }
     virtual bool isFontValue() { return false; }
+    virtual bool isImageGeneratorValue() const { return false; }
+    virtual bool isImageValue() const { return false; }
     virtual bool isImplicitInitialValue() const { return false; }
+    virtual bool isPrimitiveValue() const { return false; }
     virtual bool isTransitionTimingFunctionValue() { return false; }
-    virtual bool isImageValue() const { return false; }
-    virtual bool isImageGeneratorValue() const { return false; }
+    virtual bool isValueList() { return false; }
+
+#if ENABLE(SVG)
+    virtual bool isSVGColor() const { return false; }
+    virtual bool isSVGPaint() const { return false; }
+#endif
+
+protected:
+    CSSValue() : StyleBase(0) { }
 };
 
 } // namespace WebCore
index acc51be89df93d37a5c9a5c5ec0f6b5a42c597c4..b61aa6a7f0c46a53cf306bbb7229bed5f8c5e8f6 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * This file is part of the DOM implementation for KDE.
- *
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -31,22 +29,33 @@ namespace WebCore {
 
 class CSSValueList : public CSSValue {
 public:
-    CSSValueList(bool isSpaceSeparated = false);
+    static PassRefPtr<CSSValueList> createCommaSeparated()
+    {
+        return adoptRef(new CSSValueList(false));
+    }
+    static PassRefPtr<CSSValueList> createSpaceSeparated()
+    {
+        return adoptRef(new CSSValueList(true));
+    }
+
     virtual ~CSSValueList();
 
     size_t length() const { return m_values.size(); }
     CSSValue* item(unsigned);
     CSSValue* itemWithoutBoundsCheck(unsigned index) { return m_values[index].get(); }
 
-    virtual bool isValueList() { return true; }
-
-    virtual unsigned short cssValueType() const;
-
     void append(PassRefPtr<CSSValue>);
     void prepend(PassRefPtr<CSSValue>);
+
     virtual String cssText() const;
 
-protected:
+private:
+    CSSValueList(bool isSpaceSeparated);
+
+    virtual bool isValueList() { return true; }
+
+    virtual unsigned short cssValueType() const;
+
     Vector<RefPtr<CSSValue> > m_values;
     bool m_isSpaceSeparated;
 };
index 9e3cef44100b2edb1d660e501673be75c30927ce..087d22a67ed936c5c2d648292c2afab8b8061a61 100644 (file)
@@ -28,7 +28,11 @@ namespace WebCore {
 
 class FontFamilyValue : public CSSPrimitiveValue {
 public:
-    FontFamilyValue(const String& familyName);
+    static PassRefPtr<FontFamilyValue> create(const String& familyName)
+    {
+        return adoptRef(new FontFamilyValue(familyName));
+    }
+
     void appendSpaceSeparated(const UChar* characters, unsigned length);
 
     const String& familyName() const { return m_familyName; }
@@ -36,6 +40,8 @@ public:
     virtual String cssText() const;
 
 private:
+    FontFamilyValue(const String& familyName);
+
     String m_familyName;
 };
 
index d52bfdd3bb2bde2e70c6bafda18046d4c30b28cd..1a0a38c16477059016ee9cb7f3f0f005615f92dd 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -24,6 +22,7 @@
 #define FontValue_h
 
 #include "CSSValue.h"
+#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
@@ -31,12 +30,14 @@ namespace WebCore {
 class CSSPrimitiveValue;
 class CSSValueList;
 
-class FontValue : public CSSValue
-{
+class FontValue : public CSSValue {
 public:
+    static PassRefPtr<FontValue> create()
+    {
+        return adoptRef(new FontValue);
+    }
+
     virtual String cssText() const;
-    
-    virtual bool isFontValue() { return true; }
 
     RefPtr<CSSPrimitiveValue> style;
     RefPtr<CSSPrimitiveValue> variant;
@@ -44,6 +45,11 @@ public:
     RefPtr<CSSPrimitiveValue> size;
     RefPtr<CSSPrimitiveValue> lineHeight;
     RefPtr<CSSValueList> family;
+
+private:
+    FontValue() { }
+
+    virtual bool isFontValue() { return true; }
 };
 
 } // namespace
index 397eb1b92da227a35a5742fc3ee9b1d2e085d7f7..452345f37d348c7ababafee7f519c302e447a099 100644 (file)
@@ -1,6 +1,4 @@
-/**
- * This file is part of the DOM implementation for KDE.
- *
+/*
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
  * Copyright (C) 2004, 2006 Apple Computer, Inc.
  *
@@ -22,8 +20,8 @@
 #include "config.h"
 #include "MediaList.h"
 
+#include "CSSImportRule.h"
 #include "CSSParser.h"
-#include "CSSRule.h"
 #include "CSSStyleSheet.h"
 #include "ExceptionCode.h"
 #include "MediaQuery.h"
@@ -82,13 +80,12 @@ MediaList::MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallb
         setMediaText("invalid", ec);
 }
 
-MediaList::MediaList(CSSRule* parentRule, const String& media, bool fallbackToDescriptor)
+MediaList::MediaList(CSSImportRule* parentRule, const String& media)
     : StyleBase(parentRule)
-    , m_fallback(fallbackToDescriptor)
+    , m_fallback(false)
 {
     ExceptionCode ec = 0;
     setMediaText(media, ec);
-    //FIXME: parsing can fail.
     if (ec)
         setMediaText("invalid", ec);
 }
@@ -98,16 +95,6 @@ MediaList::~MediaList()
     deleteAllValues(m_queries);
 }
 
-CSSStyleSheet *MediaList::parentStyleSheet() const
-{
-    return parent()->isCSSStyleSheet() ? static_cast<CSSStyleSheet*>(parent()) : 0;
-}
-
-CSSRule *MediaList::parentRule() const
-{
-    return parent()->isRule() ? static_cast<CSSRule*>(parent()) : 0;
-}
-
 static String parseMediaDescriptor(const String& s)
 {
     int len = s.length();
@@ -131,15 +118,15 @@ static String parseMediaDescriptor(const String& s)
 
 void MediaList::deleteMedium(const String& oldMedium, ExceptionCode& ec)
 {
-    MediaList tempMediaList;
+    RefPtr<MediaList> tempMediaList = MediaList::create();
     CSSParser p(true);
 
     MediaQuery* oldQuery = 0;
     bool deleteOldQuery = false;
 
-    if (p.parseMediaQuery(&tempMediaList, oldMedium)) {
-        if (tempMediaList.m_queries.size() > 0)
-            oldQuery = tempMediaList.m_queries[0];
+    if (p.parseMediaQuery(tempMediaList.get(), oldMedium)) {
+        if (tempMediaList->m_queries.size() > 0)
+            oldQuery = tempMediaList->m_queries[0];
     } else if (m_fallback) {
         String medium = parseMediaDescriptor(oldMedium);
         if (!medium.isNull()) {
@@ -187,7 +174,7 @@ String MediaList::mediaText() const
 
 void MediaList::setMediaText(const String& value, ExceptionCode& ec)
 {
-    MediaList tempMediaList;
+    RefPtr<MediaList> tempMediaList = MediaList::create();
     CSSParser p(true);
 
     Vector<String> list;
@@ -196,11 +183,11 @@ void MediaList::setMediaText(const String& value, ExceptionCode& ec)
     for (Vector<String>::const_iterator it = list.begin(); it != end; ++it) {
         String medium = (*it).stripWhiteSpace();
         if (!medium.isEmpty()) {
-            if (!p.parseMediaQuery(&tempMediaList, medium)) {
+            if (!p.parseMediaQuery(tempMediaList.get(), medium)) {
                 if (m_fallback) {
                     String mediaDescriptor = parseMediaDescriptor(medium);
                     if (!mediaDescriptor.isNull())
-                        tempMediaList.m_queries.append(new MediaQuery(MediaQuery::None, mediaDescriptor, 0));
+                        tempMediaList->m_queries.append(new MediaQuery(MediaQuery::None, mediaDescriptor, 0));
                 } else {
                     ec = SYNTAX_ERR;
                     return;
@@ -222,8 +209,8 @@ void MediaList::setMediaText(const String& value, ExceptionCode& ec)
     
     ec = 0;
     deleteAllValues(m_queries);
-    m_queries = tempMediaList.m_queries;
-    tempMediaList.m_queries.clear();
+    m_queries = tempMediaList->m_queries;
+    tempMediaList->m_queries.clear();
     notifyChanged();
 }
 
index 3b27e1f8e2be2e8c369146d101b80ca80b092a87..f1eb0c03ec0a49b45c48b3d56961290b1d68c837 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * This file is part of the DOM implementation for KDE.
- *
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #define MediaList_h
 
 #include "StyleBase.h"
+#include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
-#include "PlatformString.h"
 
 namespace WebCore {
-typedef int ExceptionCode;
+
+class CSSImportRule;
 class CSSStyleSheet;
 class MediaQuery;
-class CSSRule;
+class String;
+
+typedef int ExceptionCode;
 
-class MediaList : public StyleBase
-{
+class MediaList : public StyleBase {
 public:
-    MediaList(bool fallbackToDescription = false) : StyleBase(0), m_fallback(fallbackToDescription) {}
-    MediaList(CSSStyleSheet* parentSheet, bool fallbackToDescription = false);
-    MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallbackToDescription = false);
-    MediaList(CSSRule* parentRule, const String& media, bool fallbackToDescription = false);
-    ~MediaList();
+    static PassRefPtr<MediaList> create()
+    {
+        return adoptRef(new MediaList(0, false));
+    }
+    static PassRefPtr<MediaList> create(CSSImportRule* parentRule, const String& media)
+    {
+        return adoptRef(new MediaList(parentRule, media));
+    }
+    static PassRefPtr<MediaList> create(CSSStyleSheet* parentSheet, const String& media)
+    {
+        return adoptRef(new MediaList(parentSheet, media, false));
+    }
+
+    static PassRefPtr<MediaList> createAllowingDescriptionSyntax(const String& mediaQueryOrDescription)
+    {
+        return adoptRef(new MediaList(0, mediaQueryOrDescription, true));
+    }
+    static PassRefPtr<MediaList> createAllowingDescriptionSyntax(CSSStyleSheet* parentSheet, const String& mediaQueryOrDescription)
+    {
+        return adoptRef(new MediaList(parentSheet, mediaQueryOrDescription, true));
+    }
 
-    virtual bool isMediaList() { return true; }
+    static PassRefPtr<MediaList> create(const String& media, bool allowDescriptionSyntax)
+    {
+        return adoptRef(new MediaList(0, media, allowDescriptionSyntax));
+    }
 
-    CSSStyleSheet* parentStyleSheet() const;
-    CSSRule* parentRule() const;
-    unsigned length() const { return (unsigned) m_queries.size(); }
+    virtual ~MediaList();
+
+    unsigned length() const { return m_queries.size(); }
     String item(unsigned index) const;
     void deleteMedium(const String& oldMedium, ExceptionCode&);
     void appendMedium(const String& newMedium, ExceptionCode&);
@@ -54,13 +73,16 @@ public:
     String mediaText() const;
     void setMediaText(const String&, ExceptionCode&xo);
 
-    void appendMediaQuery(MediaQuery* mediaQuery);
-    const Vector<MediaQuery*>* mediaQueries() const { return &m_queries; }
+    void appendMediaQuery(MediaQuery*);
+    const Vector<MediaQuery*>& mediaQueries() const { return m_queries; }
 
 private:
+    MediaList(CSSStyleSheet* parentSheet, bool fallbackToDescription);
+    MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallbackToDescription);
+    MediaList(CSSImportRule* parentRule, const String& media);
+
     void notifyChanged();
 
-protected:
     Vector<MediaQuery*> m_queries;
     bool m_fallback; // true if failed media query parsing should fallback to media description parsing
 };
index 9e8a3050872ba2a5a8a1eb8486b8463681278502..4be22aced82388283c036142263e7e6d4a16d971 100644 (file)
@@ -128,14 +128,14 @@ bool MediaQueryEvaluator::eval(const MediaList* mediaList, CSSStyleSelector* sty
     if (!mediaList)
         return true;
 
-    const Vector<MediaQuery*>* queries = mediaList->mediaQueries();
-    if (!queries->size())
+    const Vector<MediaQuery*>& queries = mediaList->mediaQueries();
+    if (!queries.size())
         return true; // empty query list evaluates to true
 
     // iterate over queries, stop if any of them eval to true (OR semantics)
     bool result = false;
-    for (size_t i = 0; i < queries->size() && !result; ++i) {
-        MediaQuery* query = queries->at(i);
+    for (size_t i = 0; i < queries.size() && !result; ++i) {
+        MediaQuery* query = queries.at(i);
 
         if (mediaTypeMatch(query->mediaType())) {
             const Vector<MediaQueryExp*>* exps = query->expressions();
index e6f9ff0574ded4d64b0591871f14d276a6213698..54340b8ea9a31535f8d3b8a2def6a6c78875e393 100644 (file)
@@ -43,27 +43,27 @@ MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, ValueList* valueL
             Value* value = valueList->current();
 
             if (value->id != 0)
-                m_value = new CSSPrimitiveValue(value->id);
+                m_value = CSSPrimitiveValue::createIdentifier(value->id);
             else if (value->unit == CSSPrimitiveValue::CSS_STRING)
-                m_value = new CSSPrimitiveValue(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
+                m_value = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
             else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER &&
                       value->unit <= CSSPrimitiveValue::CSS_KHZ)
-                m_value = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
+                m_value = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
 
             valueList->next();
         } else if (valueList->size() > 1) {
             // create list of values
             // currently accepts only <integer>/<integer>
 
-            CSSValueList* list = new CSSValueList();
+            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
             Value* value = 0;
             bool isValid = true;
 
             while ((value = valueList->current()) && isValid) {
                 if (value->unit == Value::Operator && value->iValue == '/')
-                    list->append(new CSSPrimitiveValue("/", CSSPrimitiveValue::CSS_STRING));
+                    list->append(CSSPrimitiveValue::create("/", CSSPrimitiveValue::CSS_STRING));
                 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
-                    list->append(new CSSPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_NUMBER));
+                    list->append(CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_NUMBER));
                 else
                     isValid = false;
 
@@ -71,9 +71,7 @@ MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, ValueList* valueL
             }
 
             if (isValid)
-                m_value = list;
-            else
-                delete list;
+                m_value = list.release();
         }
     }
 }
index 9b36d750039eca6eee70c233e7fcede6a9ed5295..e598c7a24e008e9eb46ac56662b053ac93345c48 100644 (file)
 
 namespace WebCore {
 
-static CSSPrimitiveValue* glyphOrientationToCSSPrimitiveValue(EGlyphOrientation orientation)
+static PassRefPtr<CSSPrimitiveValue> glyphOrientationToCSSPrimitiveValue(EGlyphOrientation orientation)
 {
     switch (orientation) {
         case GO_0DEG:
-            return new CSSPrimitiveValue(0.0f, CSSPrimitiveValue::CSS_DEG);
+            return CSSPrimitiveValue::create(0.0f, CSSPrimitiveValue::CSS_DEG);
         case GO_90DEG:
-            return new CSSPrimitiveValue(90.0f, CSSPrimitiveValue::CSS_DEG);
+            return CSSPrimitiveValue::create(90.0f, CSSPrimitiveValue::CSS_DEG);
         case GO_180DEG:
-            return new CSSPrimitiveValue(180.0f, CSSPrimitiveValue::CSS_DEG);
+            return CSSPrimitiveValue::create(180.0f, CSSPrimitiveValue::CSS_DEG);
         case GO_270DEG:
-            return new CSSPrimitiveValue(270.0f, CSSPrimitiveValue::CSS_DEG);
+            return CSSPrimitiveValue::create(270.0f, CSSPrimitiveValue::CSS_DEG);
         default:
             return 0;
     }
@@ -65,79 +65,79 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
     
     switch (static_cast<CSSPropertyID>(propertyID)) {
         case CSSPropertyClipRule:
-            return new CSSPrimitiveValue(svgStyle->clipRule());
+            return CSSPrimitiveValue::create(svgStyle->clipRule());
         case CSSPropertyFloodOpacity:
-            return new CSSPrimitiveValue(svgStyle->floodOpacity(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(svgStyle->floodOpacity(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyStopOpacity:
-            return new CSSPrimitiveValue(svgStyle->stopOpacity(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(svgStyle->stopOpacity(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyPointerEvents:
-            return new CSSPrimitiveValue(svgStyle->pointerEvents());
+            return CSSPrimitiveValue::create(svgStyle->pointerEvents());
         case CSSPropertyColorInterpolation:
-            return new CSSPrimitiveValue(svgStyle->colorInterpolation());
+            return CSSPrimitiveValue::create(svgStyle->colorInterpolation());
         case CSSPropertyColorInterpolationFilters:
-            return new CSSPrimitiveValue(svgStyle->colorInterpolationFilters());
+            return CSSPrimitiveValue::create(svgStyle->colorInterpolationFilters());
         case CSSPropertyFillOpacity:
-            return new CSSPrimitiveValue(svgStyle->fillOpacity(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(svgStyle->fillOpacity(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyFillRule:
-            return new CSSPrimitiveValue(svgStyle->fillRule());
+            return CSSPrimitiveValue::create(svgStyle->fillRule());
         case CSSPropertyColorRendering:
-            return new CSSPrimitiveValue(svgStyle->colorRendering());
+            return CSSPrimitiveValue::create(svgStyle->colorRendering());
         case CSSPropertyImageRendering:
-            return new CSSPrimitiveValue(svgStyle->imageRendering());
+            return CSSPrimitiveValue::create(svgStyle->imageRendering());
         case CSSPropertyShapeRendering:
-            return new CSSPrimitiveValue(svgStyle->shapeRendering());
+            return CSSPrimitiveValue::create(svgStyle->shapeRendering());
         case CSSPropertyStrokeLinecap:
-            return new CSSPrimitiveValue(svgStyle->capStyle());
+            return CSSPrimitiveValue::create(svgStyle->capStyle());
         case CSSPropertyStrokeLinejoin:
-            return new CSSPrimitiveValue(svgStyle->joinStyle());
+            return CSSPrimitiveValue::create(svgStyle->joinStyle());
         case CSSPropertyStrokeMiterlimit:
-            return new CSSPrimitiveValue(svgStyle->strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(svgStyle->strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyStrokeOpacity:
-            return new CSSPrimitiveValue(svgStyle->strokeOpacity(), CSSPrimitiveValue::CSS_NUMBER);
+            return CSSPrimitiveValue::create(svgStyle->strokeOpacity(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyTextRendering:
-            return new CSSPrimitiveValue(svgStyle->textRendering());
+            return CSSPrimitiveValue::create(svgStyle->textRendering());
         case CSSPropertyAlignmentBaseline:
-            return new CSSPrimitiveValue(svgStyle->alignmentBaseline());
+            return CSSPrimitiveValue::create(svgStyle->alignmentBaseline());
         case CSSPropertyDominantBaseline:
-            return new CSSPrimitiveValue(svgStyle->dominantBaseline());
+            return CSSPrimitiveValue::create(svgStyle->dominantBaseline());
         case CSSPropertyTextAnchor:
-            return new CSSPrimitiveValue(svgStyle->textAnchor());
+            return CSSPrimitiveValue::create(svgStyle->textAnchor());
         case CSSPropertyWritingMode:
-            return new CSSPrimitiveValue(svgStyle->writingMode());
+            return CSSPrimitiveValue::create(svgStyle->writingMode());
         case CSSPropertyClipPath:
             if (!svgStyle->clipPath().isEmpty())
-                return new CSSPrimitiveValue(svgStyle->clipPath(), CSSPrimitiveValue::CSS_URI);
-            return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::create(svgStyle->clipPath(), CSSPrimitiveValue::CSS_URI);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyMask:
             if (!svgStyle->maskElement().isEmpty())
-                return new CSSPrimitiveValue(svgStyle->maskElement(), CSSPrimitiveValue::CSS_URI);
-            return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::create(svgStyle->maskElement(), CSSPrimitiveValue::CSS_URI);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyFilter:
             if (!svgStyle->filter().isEmpty())
-                return new CSSPrimitiveValue(svgStyle->filter(), CSSPrimitiveValue::CSS_URI);
-            return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::create(svgStyle->filter(), CSSPrimitiveValue::CSS_URI);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyFloodColor:
-            return new CSSPrimitiveValue(svgStyle->floodColor().rgb());
+            return CSSPrimitiveValue::createColor(svgStyle->floodColor().rgb());
         case CSSPropertyLightingColor:
-            return new CSSPrimitiveValue(svgStyle->lightingColor().rgb());
+            return CSSPrimitiveValue::createColor(svgStyle->lightingColor().rgb());
         case CSSPropertyStopColor:
-            return new CSSPrimitiveValue(svgStyle->stopColor().rgb());
+            return CSSPrimitiveValue::createColor(svgStyle->stopColor().rgb());
         case CSSPropertyFill:
             return svgStyle->fillPaint();
         case CSSPropertyKerning:
             return svgStyle->kerning();
         case CSSPropertyMarkerEnd:
             if (!svgStyle->endMarker().isEmpty())
-                return new CSSPrimitiveValue(svgStyle->endMarker(), CSSPrimitiveValue::CSS_URI);
-            return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::create(svgStyle->endMarker(), CSSPrimitiveValue::CSS_URI);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyMarkerMid:
             if (!svgStyle->midMarker().isEmpty())
-                return new CSSPrimitiveValue(svgStyle->midMarker(), CSSPrimitiveValue::CSS_URI);
-            return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::create(svgStyle->midMarker(), CSSPrimitiveValue::CSS_URI);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyMarkerStart:
             if (!svgStyle->startMarker().isEmpty())
-                return new CSSPrimitiveValue(svgStyle->startMarker(), CSSPrimitiveValue::CSS_URI);
-            return new CSSPrimitiveValue(CSSValueNone);
+                return CSSPrimitiveValue::create(svgStyle->startMarker(), CSSPrimitiveValue::CSS_URI);
+            return CSSPrimitiveValue::createIdentifier(CSSValueNone);
         case CSSPropertyStroke:
             return svgStyle->strokePaint();
         case CSSPropertyStrokeDasharray:
@@ -149,11 +149,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
         case CSSPropertyBaselineShift: {
             switch (svgStyle->baselineShift()) {
                 case BS_BASELINE:
-                    return new CSSPrimitiveValue(CSSValueBaseline);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueBaseline);
                 case BS_SUPER:
-                    return new CSSPrimitiveValue(CSSValueSuper);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueSuper);
                 case BS_SUB:
-                    return new CSSPrimitiveValue(CSSValueSub);
+                    return CSSPrimitiveValue::createIdentifier(CSSValueSub);
                 case BS_LENGTH:
                     return svgStyle->baselineShiftValue();
             }
@@ -161,11 +161,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int pro
         case CSSPropertyGlyphOrientationHorizontal:
             return glyphOrientationToCSSPrimitiveValue(svgStyle->glyphOrientationHorizontal());
         case CSSPropertyGlyphOrientationVertical: {
-            if (CSSPrimitiveValue* value = glyphOrientationToCSSPrimitiveValue(svgStyle->glyphOrientationVertical()))
-                return value;
+            if (RefPtr<CSSPrimitiveValue> value = glyphOrientationToCSSPrimitiveValue(svgStyle->glyphOrientationVertical()))
+                return value.release();
 
             if (svgStyle->glyphOrientationVertical() == GO_AUTO)
-                return new CSSPrimitiveValue(CSSValueAuto);
+                return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
 
             return 0;
         }
index c6a45c179284d410b5049c63aecb93e3ad9684a9..4dffea8ee13be70c4b6577e57dd17328578add3a 100644 (file)
@@ -92,7 +92,7 @@ bool CSSParser::parseSVGValue(int propId, bool important)
         if (id == CSSValueNone)
             valid_primitive = true;
         else if (value->unit == CSSPrimitiveValue::CSS_URI) {
-            parsedValue = new CSSPrimitiveValue(value->string, CSSPrimitiveValue::CSS_URI);
+            parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_URI);
             if (parsedValue)
                 m_valueList->next();
         }
@@ -181,7 +181,7 @@ bool CSSParser::parseSVGValue(int propId, bool important)
     /* fallthrough intentional */
     case CSSPropertyGlyphOrientationHorizontal: // <angle> (restricted to _deg_ per SVG 1.1 spec) | inherit
         if (value->unit == CSSPrimitiveValue::CSS_DEG || value->unit == CSSPrimitiveValue::CSS_NUMBER) {
-            parsedValue = new CSSPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_DEG);
+            parsedValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_DEG);
 
             if (parsedValue)
                 m_valueList->next();
@@ -192,15 +192,15 @@ bool CSSParser::parseSVGValue(int propId, bool important)
     case CSSPropertyStroke:               // <paint> | inherit
         {
             if (id == CSSValueNone)
-                parsedValue = new SVGPaint(SVGPaint::SVG_PAINTTYPE_NONE);
+                parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_NONE);
             else if (id == CSSValueCurrentcolor)
-                parsedValue = new SVGPaint(SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR);
+                parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR);
             else if (value->unit == CSSPrimitiveValue::CSS_URI) {
                 RGBA32 c = Color::transparent;
                 if (m_valueList->next() && parseColorFromValue(m_valueList->current(), c, true)) {
-                    parsedValue = new SVGPaint(value->string, c);
+                    parsedValue = SVGPaint::create(value->string, c);
                 } else
-                    parsedValue = new SVGPaint(SVGPaint::SVG_PAINTTYPE_URI, value->string);
+                    parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_URI, value->string);
             } else
                 parsedValue = parseSVGPaint();
 
@@ -212,7 +212,7 @@ bool CSSParser::parseSVGValue(int propId, bool important)
     case CSSPropertyColor:                // <color> | inherit
         if ((id >= CSSValueAqua && id <= CSSValueWindowtext) ||
            (id >= CSSValueAliceblue && id <= CSSValueYellowgreen))
-            parsedValue = new SVGColor(value->string);
+            parsedValue = SVGColor::create(value->string);
         else
             parsedValue = parseSVGColor();
 
@@ -225,9 +225,9 @@ bool CSSParser::parseSVGValue(int propId, bool important)
     case CSSPropertyLightingColor:
         if ((id >= CSSValueAqua && id <= CSSValueWindowtext) ||
            (id >= CSSValueAliceblue && id <= CSSValueYellowgreen))
-            parsedValue = new SVGColor(value->string);
+            parsedValue = SVGColor::create(value->string);
         else if (id == CSSValueCurrentcolor)
-            parsedValue = new SVGColor(SVGColor::SVG_COLORTYPE_CURRENTCOLOR);
+            parsedValue = SVGColor::createCurrentColor();
         else // TODO : svgcolor (iccColor)
             parsedValue = parseSVGColor();
 
@@ -266,7 +266,7 @@ bool CSSParser::parseSVGValue(int propId, bool important)
         if (id == CSSValueNone)
             valid_primitive = true;
         else if (value->unit == CSSPrimitiveValue::CSS_URI) {
-            parsedValue = new CSSPrimitiveValue(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
+            parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
             if (parsedValue)
                 m_valueList->next();
         }
@@ -298,13 +298,13 @@ bool CSSParser::parseSVGValue(int propId, bool important)
 
     if (valid_primitive) {
         if (id != 0)
-            parsedValue = new CSSPrimitiveValue(id);
+            parsedValue = CSSPrimitiveValue::createIdentifier(id);
         else if (value->unit == CSSPrimitiveValue::CSS_STRING)
-            parsedValue = new CSSPrimitiveValue(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
+            parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
         else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
-            parsedValue = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
+            parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
         else if (value->unit >= Value::Q_EMS)
-            parsedValue = new CSSQuirkPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_EMS);
+            parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
         m_valueList->next();
     }
     if (!parsedValue || (m_valueList->current() && !inShorthand()))
@@ -316,7 +316,7 @@ bool CSSParser::parseSVGValue(int propId, bool important)
 
 PassRefPtr<CSSValue> CSSParser::parseSVGStrokeDasharray()
 {
-    CSSValueList* ret = new CSSValueList;
+    RefPtr<CSSValueList> ret = CSSValueList::createCommaSeparated();
     Value* value = m_valueList->current();
     bool valid_primitive = true;
     while (value) {
@@ -324,27 +324,24 @@ PassRefPtr<CSSValue> CSSParser::parseSVGStrokeDasharray()
         if (!valid_primitive)
             break;
         if (value->id != 0)
-            ret->append(new CSSPrimitiveValue(value->id));
+            ret->append(CSSPrimitiveValue::createIdentifier(value->id));
         else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
-            ret->append(new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit));
+            ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit));
         value = m_valueList->next();
         if (value && value->unit == Value::Operator && value->iValue == ',')
             value = m_valueList->next();
     }
-    if (!valid_primitive) {
-        delete ret;
-        ret = 0;
-    }
-
-    return ret;
+    if (!valid_primitive)
+        return 0;
+    return ret.release();
 }
 
 PassRefPtr<CSSValue> CSSParser::parseSVGPaint()
 {
     RGBA32 c = Color::transparent;
     if (!parseColorFromValue(m_valueList->current(), c, true))
-        return new SVGPaint();
-    return new SVGPaint(Color(c));
+        return SVGPaint::create();
+    return SVGPaint::create(Color(c));
 }
 
 PassRefPtr<CSSValue> CSSParser::parseSVGColor()
@@ -352,7 +349,7 @@ PassRefPtr<CSSValue> CSSParser::parseSVGColor()
     RGBA32 c = Color::transparent;
     if (!parseColorFromValue(m_valueList->current(), c, true))
         return 0;
-    return new SVGColor(Color(c));
+    return SVGColor::create(Color(c));
 }
 
 }
index 2f94b9442bfb6d8f419ab9c756dcea00bd006949..179531eccf2de5376994fcb3f4b8f2b06ceb60ff 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * 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.
+ * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -32,20 +30,28 @@ namespace WebCore {
 class CSSPrimitiveValue;
 
 // Used for text-shadow and box-shadow
-class ShadowValue : public CSSValue
-{
+class ShadowValue : public CSSValue {
 public:
-    ShadowValue(PassRefPtr<CSSPrimitiveValue> x,
+    static PassRefPtr<ShadowValue> create(PassRefPtr<CSSPrimitiveValue> x,
         PassRefPtr<CSSPrimitiveValue> y,
         PassRefPtr<CSSPrimitiveValue> blur,
-        PassRefPtr<CSSPrimitiveValue> color);
-    
+        PassRefPtr<CSSPrimitiveValue> color)
+    {
+        return adoptRef(new ShadowValue(x, y, blur, color));
+    }
+
     virtual String cssText() const;
 
     RefPtr<CSSPrimitiveValue> x;
     RefPtr<CSSPrimitiveValue> y;
     RefPtr<CSSPrimitiveValue> blur;
     RefPtr<CSSPrimitiveValue> color;
+
+private:
+    ShadowValue(PassRefPtr<CSSPrimitiveValue> x,
+        PassRefPtr<CSSPrimitiveValue> y,
+        PassRefPtr<CSSPrimitiveValue> blur,
+        PassRefPtr<CSSPrimitiveValue> color);
 };
 
 } // namespace
index 020dbd3c81867b6d1033f42d41c84fe50e5fc4f9..b012c3243ba011d6ed50b2ef5713ba5860aadcb9 100644 (file)
@@ -31,15 +31,13 @@ namespace WebCore {
     class StyleSheet;
     class KURL;
 
-    // a style class which has a parent (almost all have)
+    // Base class for most CSS DOM objects.
+
+    // FIXME: We don't need these to all share one base class.
+    // Refactor so they don't any more.
+
     class StyleBase : public RefCounted<StyleBase> {
     public:
-        StyleBase(StyleBase* parent)
-            : RefCounted<StyleBase>(0)
-            , m_parent(parent)
-            , m_strictParsing(!parent || parent->useStrictParsing())
-        {
-        }
         virtual ~StyleBase() { }
 
         StyleBase* parent() const { return m_parent; }
@@ -48,31 +46,16 @@ namespace WebCore {
         // returns the url of the style sheet this object belongs to
         KURL baseURL() const;
 
-        virtual bool isStyleSheet() const { return false; }
         virtual bool isCSSStyleSheet() const { return false; }
-        virtual bool isXSLStyleSheet() const { return false; }
-        virtual bool isStyleSheetList() const { return false; }
-        virtual bool isMediaList() { return false; }
-        virtual bool isRuleList() { return false; }
-        virtual bool isRule() { return false; }
-        virtual bool isStyleRule() { return false; }
         virtual bool isCharsetRule() { return false; }
+        virtual bool isFontFaceRule() { return false; }
         virtual bool isImportRule() { return false; }
         virtual bool isMediaRule() { return false; }
-        virtual bool isFontFaceRule() { return false; }
-        virtual bool isPageRule() { return false; }
-        virtual bool isUnknownRule() { return false; }
-        virtual bool isStyleDeclaration() { return false; }
-        virtual bool isValue() { return false; }
-        virtual bool isPrimitiveValue() const { return false; }
-        virtual bool isValueList() { return false; }
-        virtual bool isValueCustom() { return false; }
-#if ENABLE(SVG)
-        virtual bool isSVGColor() const { return false; }
-        virtual bool isSVGPaint() const { return false; }
-#endif
+        virtual bool isRule() { return false; }
+        virtual bool isStyleRule() { return false; }
+        virtual bool isStyleSheet() const { return false; }
+        virtual bool isXSLStyleSheet() const { return false; }
 
-        virtual bool parseString(const String&, bool /*strict*/ = false) { return false; }
         virtual void checkLoaded();
 
         void setStrictParsing(bool b) { m_strictParsing = b; }
@@ -82,6 +65,13 @@ namespace WebCore {
 
         StyleSheet* stylesheet();
 
+    protected:
+        StyleBase(StyleBase* parent)
+            : m_parent(parent)
+            , m_strictParsing(!parent || parent->useStrictParsing())
+        {
+        }
+
     private:
         StyleBase* m_parent;
         bool m_strictParsing;
index 412509ea813988278b7c8602cc5a0c734905b71a..25104702aecd6369555faeb800376dcf9d56f30b 100644 (file)
@@ -1,11 +1,9 @@
 /*
- * This file is part of the DOM implementation for KDE.
- *
  * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
  *               1999 Waldo Bastian (bastian@kde.org)
  *               2001 Andreas Schlapbach (schlpbch@iam.unibe.ch)
  *               2001-2003 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2002, 2006 Apple Computer, Inc.
+ * Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
+
 #include "config.h"
 #include "StyleList.h"
 
+#include <wtf/PassRefPtr.h>
+
 namespace WebCore {
 
 void StyleList::append(PassRefPtr<StyleBase> child)
index 2a4e11251214d9f67b9dcc1d1af35057a49f6111..ceca28a3727b5a56aa687b372e1c6af0fcec317a 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * This file is part of the CSS implementation for KDE.
- *
  * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
  *               1999 Waldo Bastian (bastian@kde.org)
- * Copyright (C) 2004, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -25,7 +23,8 @@
 #define StyleList_h
 
 #include "StyleBase.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
+#include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -33,8 +32,6 @@ namespace WebCore {
     // a style class which has a list of children (StyleSheets for example)
     class StyleList : public StyleBase {
     public:
-        StyleList(StyleBase* parent) : StyleBase(parent) { }
-
         unsigned length() { return m_children.size(); }
         StyleBase* item(unsigned num) { return num < length() ? m_children[num].get() : 0; }
 
@@ -43,6 +40,8 @@ namespace WebCore {
         void remove(unsigned position);
 
     protected:
+        StyleList(StyleBase* parent) : StyleBase(parent) { }
+
         Vector<RefPtr<StyleBase> > m_children;
     };
 }
index ffe9864d2dc01734e9fd05da663dfdef62154b86..9384fc8a22112467e491944b5e7709f0b5cc1bfe 100644 (file)
@@ -1,8 +1,6 @@
 /*
- * This file is part of the DOM implementation for KDE.
- *
  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 #include "StyleList.h"
 #include "PlatformString.h"
-
 #include <wtf/HashSet.h>
 
 namespace WebCore {
 
-class Node;
 class CachedCSSStyleSheet;
 class MediaList;
+class Node;
 
 class StyleSheet : public StyleList {
 public:
-    StyleSheet(Node* ownerNode, const String& href = String());
-    StyleSheet(StyleSheet* parentSheet, const String& href = String());
-    StyleSheet(StyleBase* owner, const String& href = String());
     virtual ~StyleSheet();
 
-    virtual bool isStyleSheet() const { return true; }
-
-    virtual String type() const { return String(); }
-
     bool disabled() const { return m_disabled; }
     void setDisabled(bool disabled) { m_disabled = disabled; styleSheetChanged(); }
 
@@ -57,13 +47,21 @@ public:
     MediaList* media() const { return m_media.get(); }
     void setMedia(PassRefPtr<MediaList>);
 
-    virtual bool isLoading() { return false; }
-
+    virtual String type() const = 0;
+    virtual bool isLoading() = 0;
     virtual void styleSheetChanged() { }
-    
     virtual void addSubresourceURLStrings(HashSet<String>&, const String& baseURL) const { }
 
+    virtual bool parseString(const String&, bool strict = true) = 0;
+
 protected:
+    StyleSheet(Node* ownerNode, const String& href);
+    StyleSheet(StyleSheet* parentSheet, const String& href);
+    StyleSheet(StyleBase* owner, const String& href);
+
+private:
+    virtual bool isStyleSheet() const { return true; }
+
     Node* m_parentNode;
     String m_strHref;
     String m_strTitle;
index cacb7de7cbb727a6fc9969def61af01cd79f0574..19ba5a0cd8fdf1119c36a65be985ac859be3f84c 100644 (file)
@@ -1,11 +1,9 @@
 /*
- * This file is part of the DOM implementation for KDE.
- *
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Peter Kelly (pmk@post.com)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -35,11 +33,11 @@ namespace WebCore {
 
 class CSSMappedAttributeDeclaration : public CSSMutableStyleDeclaration {
 public:
-    CSSMappedAttributeDeclaration(CSSRule* parentRule)
-        : CSSMutableStyleDeclaration(parentRule)
-        , m_entryType(eNone)
-        , m_attrName(anyQName()) { }
-    
+    static PassRefPtr<CSSMappedAttributeDeclaration> create()
+    {
+        return adoptRef(new CSSMappedAttributeDeclaration(0));
+    }
+
     virtual ~CSSMappedAttributeDeclaration();
 
     void setMappedState(MappedAttributeEntry type, const QualifiedName& name, const AtomicString& val)
@@ -50,6 +48,13 @@ public:
     }
 
 private:
+    CSSMappedAttributeDeclaration(CSSRule* parentRule)
+        : CSSMutableStyleDeclaration(parentRule)
+        , m_entryType(eNone)
+        , m_attrName(anyQName())
+    {
+    }
+    
     MappedAttributeEntry m_entryType;
     QualifiedName m_attrName;
     AtomicString m_attrValue;
index 18021c3555aea49a040d67d30a9421ede2432996..2d402b3a56c66a3995e7dfbd95c1fe9eebd22d6a 100644 (file)
@@ -248,13 +248,12 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& namespaceUR
     return doc.release();
 }
 
-PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media, ExceptionCode& ec)
+PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media, ExceptionCode&)
 {
-    // ### TODO : title should be set, and media could have wrong syntax, in which case we should generate an exception.
-    ec = 0;
-    CSSStyleSheet* const nullSheet = 0;
-    RefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(nullSheet);
-    sheet->setMedia(new MediaList(sheet.get(), media, true));
+    // FIXME: Title should be set.
+    // FIXME: Media could have wrong syntax, in which case we should generate an exception.
+    RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::create();
+    sheet->setMedia(MediaList::createAllowingDescriptionSyntax(sheet.get(), media));
     return sheet.release();
 }
 
index b67923ee69072be87299194a3393f62830100cd7..f69177889b9c9a294e77b72e1c995283c1638020 100644 (file)
@@ -581,7 +581,7 @@ PassRefPtr<EditingText> Document::createEditingTextNode(const String& text)
 
 PassRefPtr<CSSStyleDeclaration> Document::createCSSStyleDeclaration()
 {
-    return new CSSMutableStyleDeclaration;
+    return CSSMutableStyleDeclaration::create();
 }
 
 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCode& ec)
@@ -1743,9 +1743,9 @@ void Document::updateBaseURL()
         m_mappedElementSheet->setHref(m_baseURL.string());
 }
 
-void Document::setCSSStyleSheet(const String &url, const String& charset, const CachedCSSStyleSheet* sheet)
+void Document::setCSSStyleSheet(const Stringurl, const String& charset, const CachedCSSStyleSheet* sheet)
 {
-    m_sheet = new CSSStyleSheet(this, url, charset);
+    m_sheet = CSSStyleSheet::create(this, url, charset);
     m_sheet->parseString(sheet->sheetText());
 
     updateStyleSelector();
@@ -1776,14 +1776,14 @@ String Document::userStyleSheet() const
 CSSStyleSheet* Document::elementSheet()
 {
     if (!m_elemSheet)
-        m_elemSheet = new CSSStyleSheet(this, m_baseURL.string());
+        m_elemSheet = CSSStyleSheet::create(this, m_baseURL.string());
     return m_elemSheet.get();
 }
 
 CSSStyleSheet* Document::mappedElementSheet()
 {
     if (!m_mappedElementSheet)
-        m_mappedElementSheet = new CSSStyleSheet(this, m_baseURL.string());
+        m_mappedElementSheet = CSSStyleSheet::create(this, m_baseURL.string());
     return m_mappedElementSheet.get();
 }
 
@@ -2209,10 +2209,10 @@ void Document::recalcStyleSelector()
                             sheetText += c->nodeValue();
                     }
 
-                    CSSStyleSheet* cssSheet = new CSSStyleSheet(this);
+                    RefPtr<CSSStyleSheet> cssSheet = CSSStyleSheet::create(this);
                     cssSheet->parseString(sheetText);
                     pi->setCSSStyleSheet(cssSheet);
-                    sheet = cssSheet;
+                    sheet = cssSheet.get();
                 }
             }
         } else if (n->isHTMLElement() && (n->hasTagName(linkTag) || n->hasTagName(styleTag))
index e3db61be929a76dfacf3bf8c9ca9fa3eed791b7c..64b48cbb99aac531e93f724ff616b54130f92634 100644 (file)
@@ -1239,9 +1239,9 @@ PassRefPtr<Element> Node::querySelector(const String& selectors, ExceptionCode&
         ec = SYNTAX_ERR;
         return 0;
     }
-    CSSStyleSheet tempStyleSheet(document());
+    RefPtr<CSSStyleSheet> tempStyleSheet = CSSStyleSheet::create(document());
     CSSParser p(true);
-    RefPtr<CSSRule> rule = p.parseRule(&tempStyleSheet, selectors + "{}");
+    RefPtr<CSSRule> rule = p.parseRule(tempStyleSheet.get(), selectors + "{}");
     if (!rule || !rule->isStyleRule()) {
         ec = SYNTAX_ERR;
         return 0;
@@ -1270,9 +1270,9 @@ PassRefPtr<NodeList> Node::querySelectorAll(const String& selectors, ExceptionCo
         ec = SYNTAX_ERR;
         return 0;
     }
-    CSSStyleSheet tempStyleSheet(document());
+    RefPtr<CSSStyleSheet> tempStyleSheet = CSSStyleSheet::create(document());
     CSSParser p(true);
-    RefPtr<CSSRule> rule = p.parseRule(&tempStyleSheet, selectors + "{}");
+    RefPtr<CSSRule> rule = p.parseRule(tempStyleSheet.get(), selectors + "{}");
     if (!rule || !rule->isStyleRule()) {
         ec = SYNTAX_ERR;
         return 0;
index 11441d3aedd85e2833d0aa4eb3f4483fd2294087..8ea78e8b1663809d4eab06f5bf9a771336f4d345 100644 (file)
@@ -92,10 +92,10 @@ Element *Position::element() const
 
 PassRefPtr<CSSComputedStyleDeclaration> Position::computedStyle() const
 {
-    Element *elem = element();
+    Elementelem = element();
     if (!elem)
         return 0;
-    return new CSSComputedStyleDeclaration(elem);
+    return WebCore::computedStyle(elem);
 }
 
 Position Position::previous(EUsingComposedCharacters usingComposedCharacters) const
index 6ebbce4959a1ce8043c5c18ac98d308ff8bca118..8b4e14609d25a320a586fdc8db5e3edc17592e3a 100644 (file)
@@ -143,7 +143,7 @@ bool ProcessingInstruction::checkStyleSheet()
                 // We need to make a synthetic XSLStyleSheet that is embedded.  It needs to be able
                 // to kick off import/include loads that can hang off some parent sheet.
                 if (m_isXSL) {
-                    m_sheet = new XSLStyleSheet(this, m_localHref, true);
+                    m_sheet = XSLStyleSheet::createEmbedded(this, m_localHref);
                     m_loading = false;
                 }
                 return !m_isXSL;
@@ -205,18 +205,19 @@ void ProcessingInstruction::setCSSStyleSheet(const String& url, const String& ch
 #if ENABLE(XSLT)
     ASSERT(!m_isXSL);
 #endif
-    m_sheet = new CSSStyleSheet(this, url, charset);
+    RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, url, charset);
+    m_sheet = newSheet;
     parseStyleSheet(sheet->sheetText());
-    m_sheet->setTitle(m_title);
-    m_sheet->setMedia(new MediaList((CSSStyleSheet*)m_sheet.get(), m_media, false));
-    m_sheet->setDisabled(m_alternate);
+    newSheet->setTitle(m_title);
+    newSheet->setMedia(MediaList::create(newSheet.get(), m_media));
+    newSheet->setDisabled(m_alternate);
 }
 
 #if ENABLE(XSLT)
 void ProcessingInstruction::setXSLStyleSheet(const String& url, const String& sheet)
 {
     ASSERT(m_isXSL);
-    m_sheet = new XSLStyleSheet(this, url);
+    m_sheet = XSLStyleSheet::create(this, url);
     parseStyleSheet(sheet);
 }
 #endif
@@ -232,7 +233,7 @@ void ProcessingInstruction::parseStyleSheet(const String& sheet)
     m_sheet->checkLoaded();
 }
 
-void ProcessingInstruction::setCSSStyleSheet(CSSStyleSheet* sheet)
+void ProcessingInstruction::setCSSStyleSheet(PassRefPtr<CSSStyleSheet> sheet)
 {
     ASSERT(!m_cachedSheet);
     ASSERT(!m_loading);
index 2f1cf346d01b1cc69f3280dc7a37eb6670cd95a1..2ee444cdab80f74df004cf233595312cbbd0d97d 100644 (file)
@@ -61,7 +61,7 @@ public:
 #if ENABLE(XSLT)
     virtual void setXSLStyleSheet(const String& url, const String& sheet);
 #endif
-    void setCSSStyleSheet(CSSStyleSheet*);
+    void setCSSStyleSheet(PassRefPtr<CSSStyleSheet>);
     bool isLoading() const;
     virtual bool sheetLoaded();
 
index 82808802385e83aaf4daf78122dc62b39f50b049..75ed3b0fab086e6b23aa426b9ae47d7e3e6cfe72 100644 (file)
@@ -77,13 +77,13 @@ void StyleElement::createSheet(Element* e, const String& text)
     // If type is empty or CSS, this is a CSS style sheet.
     const AtomicString& type = this->type();
     if (type.isEmpty() || (e->isHTMLElement() ? equalIgnoringCase(type, "text/css") : (type == "text/css"))) {
-        RefPtr<MediaList> mediaList = new MediaList((CSSStyleSheet*)0, media(), e->isHTMLElement());
+        RefPtr<MediaList> mediaList = MediaList::create(media(), e->isHTMLElement());
         MediaQueryEvaluator screenEval("screen", true);
         MediaQueryEvaluator printEval("print", true);
         if (screenEval.eval(mediaList.get()) || printEval.eval(mediaList.get())) {
             document->addPendingSheet();
             setLoading(true);
-            m_sheet = new CSSStyleSheet(e, String(), document->inputEncoding());
+            m_sheet = CSSStyleSheet::create(e, String(), document->inputEncoding());
             m_sheet->parseString(text, !document->inCompatMode());
             m_sheet->setMedia(mediaList.get());
             m_sheet->setTitle(e->title());
index f5aef906b3ebc0d78cac37f083becff27ee9e2f4..51e9e274f397bfc55adc223b4de80b30724e60ce 100644 (file)
@@ -131,7 +131,7 @@ PassRefPtr<Attribute> StyledElement::createAttribute(const QualifiedName& name,
 
 void StyledElement::createInlineStyleDecl()
 {
-    m_inlineStyleDecl = new CSSMutableStyleDeclaration;
+    m_inlineStyleDecl = CSSMutableStyleDeclaration::create();
     m_inlineStyleDecl->setParent(document()->elementSheet());
     m_inlineStyleDecl->setNode(this);
     m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inCompatMode());
@@ -408,7 +408,7 @@ void StyledElement::addCSSColor(MappedAttribute* attr, int id, const String& c)
 
 void StyledElement::createMappedDecl(MappedAttribute* attr)
 {
-    CSSMappedAttributeDeclaration* decl = new CSSMappedAttributeDeclaration(0);
+    RefPtr<CSSMappedAttributeDeclaration> decl = CSSMappedAttributeDeclaration::create();
     attr->setDecl(decl);
     decl->setParent(document()->elementSheet());
     decl->setNode(this);
index 42e14a4ac250dab18cfef9af2f5e0e884d9ee44a..887ae3cdec5bf2f29befbc1a7a0ed1f2c63ce8ce 100644 (file)
@@ -295,7 +295,7 @@ ApplyStyleCommand::ApplyStyleCommand(Document* document, CSSStyleDeclaration* st
 
 ApplyStyleCommand::ApplyStyleCommand(Element* element, bool removeOnly, EditAction editingAction)
     : CompositeEditCommand(element->document())
-    , m_style(new CSSMutableStyleDeclaration())
+    , m_style(CSSMutableStyleDeclaration::create())
     , m_editingAction(editingAction)
     , m_propertyLevel(PropertyDefault)
     , m_start(endingSelection().start().downstream())
@@ -799,9 +799,7 @@ static bool hasTextDecorationProperty(Node *node)
     if (!node->isElementNode())
         return false;
 
-    Element *element = static_cast<Element *>(node);
-    CSSComputedStyleDeclaration style(element);
-    RefPtr<CSSValue> value = style.getPropertyCSSValue(CSSPropertyTextDecoration, DoNotUpdateLayout);
+    RefPtr<CSSValue> value = computedStyle(node)->getPropertyCSSValue(CSSPropertyTextDecoration, DoNotUpdateLayout);
     return value && !equalIgnoringCase(value->cssText(), "none");
 }
 
@@ -841,7 +839,7 @@ PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractTextDecorationS
     return textDecorationStyle.release();
 }
 
-PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractAndNegateTextDecorationStyle(Node *node)
+PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractAndNegateTextDecorationStyle(Nodenode)
 {
     ASSERT(node);
     ASSERT(node->isElementNode());
@@ -850,14 +848,13 @@ PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractAndNegateTextDe
     if (!node->isHTMLElement())
         return 0;
 
-    HTMLElement *element = static_cast<HTMLElement *>(node);
-    RefPtr<CSSComputedStyleDeclaration> computedStyle = new CSSComputedStyleDeclaration(element);
-    ASSERT(computedStyle);
+    RefPtr<CSSComputedStyleDeclaration> nodeStyle = computedStyle(node);
+    ASSERT(nodeStyle);
 
     int properties[1] = { CSSPropertyTextDecoration };
-    RefPtr<CSSMutableStyleDeclaration> textDecorationStyle = computedStyle->copyPropertiesInSet(properties, 1);
+    RefPtr<CSSMutableStyleDeclaration> textDecorationStyle = nodeStyle->copyPropertiesInSet(properties, 1);
 
-    RefPtr<CSSValue> property = computedStyle->getPropertyCSSValue(CSSPropertyTextDecoration);
+    RefPtr<CSSValue> property = nodeStyle->getPropertyCSSValue(CSSPropertyTextDecoration);
     if (property && !equalIgnoringCase(property->cssText(), "none")) {
         RefPtr<CSSMutableStyleDeclaration> newStyle = textDecorationStyle->copy();
         newStyle->setProperty(CSSPropertyTextDecoration, "none");
index 0fd90b19ef1d9d581c8dbd0734900d7f023cf1d8..4a38689dd59b91b67fb700c3017bf802e6c7d3a1 100644 (file)
@@ -859,8 +859,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
     appendBlockPlaceholder(newBlock.get());
     setEndingSelection(Selection(Position(newBlock.get(), 0), DOWNSTREAM));
     
-    CSSComputedStyleDeclaration endingStyle(endingSelection().start().node());
-    endingStyle.diff(style.get());
+    computedStyle(endingSelection().start().node())->diff(style.get());
     if (style->length() > 0)
         applyStyle(style.get());
     
index 01b2e0c2b5f95420044c5d2d08c4c71f436d8081..b02c6b64643952fc1a334f74c504e65944fb8247 100644 (file)
@@ -629,7 +629,7 @@ void DeleteSelectionCommand::calculateTypingStyleAfterDelete(Node *insertedPlace
         m_typingStyle = m_deleteIntoBlockquoteStyle;
     m_deleteIntoBlockquoteStyle = 0;
     
-    RefPtr<CSSComputedStyleDeclaration> endingStyle = new CSSComputedStyleDeclaration(m_endingPosition.node());
+    RefPtr<CSSComputedStyleDeclaration> endingStyle = computedStyle(m_endingPosition.node());
     endingStyle->diff(m_typingStyle.get());
     if (!m_typingStyle->length())
         m_typingStyle = 0;
index 71ea7366431fc3be98f760516cef3423c7f5a8d3..5a503ec9e679652a1f2e41654939e63362ca8391 100644 (file)
@@ -717,9 +717,9 @@ TriState Editor::selectionHasStyle(CSSStyleDeclaration* style) const
         }
     } else {
         for (Node* node = m_frame->selection()->start().node(); node; node = node->traverseNextNode()) {
-            RefPtr<CSSComputedStyleDeclaration> computedStyle = new CSSComputedStyleDeclaration(node);
-            if (computedStyle)
-                updateState(mutableStyle.get(), computedStyle.get(), atStart, state);
+            RefPtr<CSSComputedStyleDeclaration> nodeStyle = computedStyle(node);
+            if (nodeStyle)
+                updateState(mutableStyle.get(), nodeStyle.get(), atStart, state);
             if (state == MixedTriState)
                 break;
             if (node == m_frame->selection()->end().node())
@@ -1100,9 +1100,9 @@ void Editor::toggleUnderline()
 
 void Editor::setBaseWritingDirection(const String& direction)
 {
-    ExceptionCode ec = 0;
 
-    RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
+    RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
+    ExceptionCode ec;
     style->setProperty(CSSPropertyDirection, direction, false, ec);
     applyParagraphStyleToSelection(style.get(), EditActionSetWritingDirection);
 }
index db67b65a3b4f5746477ed165db2c45f7fa83c5c8..f81056966f1e6fa997fa74ef336e96e357fb685b 100644 (file)
@@ -87,7 +87,7 @@ static Frame* targetFrame(Frame* frame, Event* event)
 
 static bool executeApplyStyle(Frame* frame, EditorCommandSource source, EditAction action, int propertyID, const String& propertyValue)
 {
-    RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
+    RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
     style->setProperty(propertyID, propertyValue);
     // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
     switch (source) {
@@ -110,7 +110,7 @@ static bool executeApplyStyle(Frame* frame, EditorCommandSource source, EditActi
 
 static bool executeApplyStyle(Frame* frame, EditorCommandSource source, EditAction action, int propertyID, int propertyValue)
 {
-    RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
+    RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
     style->setProperty(propertyID, propertyValue);
     // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
     switch (source) {
@@ -128,7 +128,7 @@ static bool executeApplyStyle(Frame* frame, EditorCommandSource source, EditActi
 
 static bool executeToggleStyle(Frame* frame, EditorCommandSource source, EditAction action, int propertyID, const char* offValue, const char* onValue)
 {
-    RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
+    RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
     style->setProperty(propertyID, onValue);
     style->setProperty(propertyID, frame->editor()->selectionStartHasStyle(style.get()) ? offValue : onValue);
     // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
@@ -147,7 +147,7 @@ static bool executeToggleStyle(Frame* frame, EditorCommandSource source, EditAct
 
 static bool executeApplyParagraphStyle(Frame* frame, EditorCommandSource source, EditAction action, int propertyID, const String& propertyValue)
 {
-    RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
+    RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
     style->setProperty(propertyID, propertyValue);
     // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
     switch (source) {
@@ -200,7 +200,7 @@ static bool expandSelectionToGranularity(Frame* frame, TextGranularity granulari
 
 static TriState stateStyle(Frame* frame, int propertyID, const char* desiredValue)
 {
-    RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
+    RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
     style->setProperty(propertyID, desiredValue);
     return frame->editor()->selectionHasStyle(style.get());
 }
index f81fad4fb618965134b8c4d45c61e6a36ec8518b..fd69ac1af69769b761c467d18614f252d7ab3539 100644 (file)
@@ -81,8 +81,7 @@ void InsertParagraphSeparatorCommand::applyStyleAfterInsertion(Node* originalEnc
     if (!m_style)
         return;
 
-    CSSComputedStyleDeclaration endingStyle(endingSelection().start().node());
-    endingStyle.diff(m_style.get());
+    computedStyle(endingSelection().start().node())->diff(m_style.get());
     if (m_style->length() > 0)
         applyStyle(m_style.get());
 }
index dbe42d79a635e702a23770b600ea3da4ed19d11c..71f401562a71475aa35d9a191169c45a7df75d9b 100644 (file)
@@ -54,8 +54,7 @@ void RemoveFormatCommand::doApply()
     // Get the default style for this editable root, it's the style that we'll give the
     // content that we're operating on.
     Node* root = frame->selection()->rootEditableElement();
-    RefPtr<CSSComputedStyleDeclaration> computedStyle = new CSSComputedStyleDeclaration(root);
-    RefPtr<CSSMutableStyleDeclaration> defaultStyle = computedStyle->copyInheritableProperties();
+    RefPtr<CSSMutableStyleDeclaration> defaultStyle = computedStyle(root)->copyInheritableProperties();
     
     // Delete the selected content.
     // FIXME: We should be able to leave this to insertText, but its delete operation
index 190968e7751abe23eeab9e0c636eb7171249fe4c..d1dffbd6eef1710c281ad428e36e978ed40e1914 100644 (file)
@@ -230,7 +230,7 @@ PassRefPtr<Node> ReplacementFragment::insertFragmentForTestRendering(Node* conte
     while (n && !n->isElementNode())
         n = n->parentNode();
     if (n) {
-        RefPtr<CSSComputedStyleDeclaration> conFontStyle = new CSSComputedStyleDeclaration(static_cast<Element*>(n));
+        RefPtr<CSSComputedStyleDeclaration> conFontStyle = computedStyle(n);
         CSSStyleDeclaration* style = holder->style();
         style->setProperty(CSSPropertyWhiteSpace, conFontStyle->getPropertyValue(CSSPropertyWhiteSpace), false, ec);
         ASSERT(ec == 0);
index 35c0d38ceb885703e3b9ff8634f5d11456c43a2f..37fbc856338511d3f136782eeee9a13967fb0179 100644 (file)
@@ -270,7 +270,7 @@ static String renderedText(const Node* node, const Range* range)
 
 static PassRefPtr<CSSMutableStyleDeclaration> styleFromMatchedRulesForElement(Element* element, bool authorOnly = true)
 {
-    RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration();
+    RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
     RefPtr<CSSRuleList> matchedRules = element->document()->styleSelector()->styleRulesForElement(element, authorOnly);
     if (matchedRules) {
         for (unsigned i = 0; i < matchedRules->length(); i++) {
@@ -481,7 +481,7 @@ static void appendStartMarkup(Vector<UChar>& result, const Node *node, const Ran
                     style = styleFromMatchedRules;
                     
                     RefPtr<CSSComputedStyleDeclaration> computedStyleForElement = computedStyle(element);
-                    RefPtr<CSSMutableStyleDeclaration> fromComputedStyle = new CSSMutableStyleDeclaration();
+                    RefPtr<CSSMutableStyleDeclaration> fromComputedStyle = CSSMutableStyleDeclaration::create();
                     
                     DeprecatedValueListConstIterator<CSSProperty> end;
                     for (DeprecatedValueListConstIterator<CSSProperty> it = style->valuesIterator(); it != end; ++it) {
index 8f0f647fc182a2fea28886b136d03e2c4ba02fd8..e8f77636243dfea8948ddea6a4ed615e730cebae 100644 (file)
@@ -56,7 +56,7 @@ HTMLBodyElement::~HTMLBodyElement()
 
 void HTMLBodyElement::createLinkDecl()
 {
-    m_linkDecl = new CSSMutableStyleDeclaration;
+    m_linkDecl = CSSMutableStyleDeclaration::create();
     m_linkDecl->setParent(document()->elementSheet());
     m_linkDecl->setNode(this);
     m_linkDecl->setStrictParsing(!document()->inCompatMode());
index e09760c7d006be39aa70961acbdae8cd73765d42..2f3da355190a295fe0b3abf66475436b7ce99270 100644 (file)
@@ -175,7 +175,7 @@ void HTMLLinkElement::process()
         MediaQueryEvaluator allEval(true);
         MediaQueryEvaluator screenEval("screen", true);
         MediaQueryEvaluator printEval("print", true);
-        RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true);
+        RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax(m_media);
         if (allEval.eval(media.get()) || screenEval.eval(media.get()) || printEval.eval(media.get())) {
 
             // Add ourselves as a pending sheet, but only if we aren't an alternate 
@@ -223,11 +223,11 @@ void HTMLLinkElement::removedFromDocument()
 void HTMLLinkElement::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet)
 {
     bool strict = !document()->inCompatMode();
-    m_sheet = new CSSStyleSheet(this, url, charset);
+    m_sheet = CSSStyleSheet::create(this, url, charset);
     m_sheet->parseString(sheet->sheetText(strict), strict);
     m_sheet->setTitle(title());
 
-    RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true);
+    RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax(m_media);
     m_sheet->setMedia(media.get());
 
     m_loading = false;
index cd487d265fd7b6d8e156dc0cedd7de8cafa4cf34..7bd5f3d6d836dfd1d5aff5e4e9fbde8f2458206b 100644 (file)
@@ -814,7 +814,7 @@ String HTMLMediaElement::pickMedia()
                     continue; 
                 if (source->hasAttribute(mediaAttr)) {
                     MediaQueryEvaluator screenEval("screen", document()->frame(), renderer() ? renderer()->style() : 0);
-                    RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, source->media(), true);
+                    RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax(source->media());
                     if (!screenEval.eval(media.get()))
                         continue;
                 }
index 4322f3dfeffe894f2fd1c130fb5063324ff64c76..65e8c457eeff0030a98572beb5bc6bdb5171ec80 100644 (file)
@@ -466,13 +466,11 @@ void HTMLTableElement::additionalAttributeStyleDecls(Vector<CSSMutableStyleDecla
     AtomicString borderValue = m_borderColorAttr ? "solid" : "outset";
     CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, tableborderAttr, borderValue);
     if (!decl) {
-        decl = new CSSMappedAttributeDeclaration(0);
+        decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.
         decl->setParent(document()->elementSheet());
         decl->setNode(this);
         decl->setStrictParsing(false); // Mapped attributes are just always quirky.
         
-        decl->ref(); // This single ref pins us in the table until the document dies.
-
         int v = m_borderColorAttr ? CSSValueSolid : CSSValueOutset;
         decl->setProperty(CSSPropertyBorderTopStyle, v, false);
         decl->setProperty(CSSPropertyBorderBottomStyle, v, false);
@@ -526,13 +524,11 @@ void HTMLTableElement::addSharedCellBordersDecl(Vector<CSSMutableStyleDeclaratio
     const AtomicString& cellborderValue = cellBorderNames[borders];
     CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, cellborderAttr, cellborderValue);
     if (!decl) {
-        decl = new CSSMappedAttributeDeclaration(0);
+        decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.
         decl->setParent(document()->elementSheet());
         decl->setNode(this);
         decl->setStrictParsing(false); // Mapped attributes are just always quirky.
         
-        decl->ref(); // This single ref pins us in the table until the document dies.
-        
         switch (borders) {
             case SolidBordersColsOnly:
                 decl->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin, false);
@@ -587,7 +583,7 @@ void HTMLTableElement::addSharedCellPaddingDecl(Vector<CSSMutableStyleDeclaratio
         String paddingValue = String::number(m_padding);
         m_paddingDecl = getMappedAttributeDecl(eUniversal, cellpaddingAttr, paddingValue);
         if (!m_paddingDecl) {
-            m_paddingDecl = new CSSMappedAttributeDeclaration(0);
+            m_paddingDecl = CSSMappedAttributeDeclaration::create();
             m_paddingDecl->setParent(document()->elementSheet());
             m_paddingDecl->setNode(this);
             m_paddingDecl->setStrictParsing(false); // Mapped attributes are just always quirky.
@@ -614,13 +610,11 @@ void HTMLTableElement::addSharedGroupDecls(bool rows, Vector<CSSMutableStyleDecl
     AtomicString rulesValue = rows ? "rowgroups" : "colgroups";
     CSSMappedAttributeDeclaration* decl = getMappedAttributeDecl(ePersistent, rulesAttr, rulesValue);
     if (!decl) {
-        decl = new CSSMappedAttributeDeclaration(0);
+        decl = CSSMappedAttributeDeclaration::create().releaseRef(); // This single ref pins us in the table until the document dies.
         decl->setParent(document()->elementSheet());
         decl->setNode(this);
         decl->setStrictParsing(false); // Mapped attributes are just always quirky.
         
-        decl->ref(); // This single ref pins us in the table until the document dies.
-        
         if (rows) {
             decl->setProperty(CSSPropertyBorderTopWidth, CSSValueThin, false);
             decl->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin, false);
index 72852a19bad43bcca372d0f8204a9fa5bcf9f914..4cf9b2a739fa98dd0f628e2db1485fe878204ca7 100644 (file)
@@ -751,8 +751,8 @@ PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const
     if (!elt)
         return 0;
 
-    // FIXME: This needs to work with pseudo elements.
-    return new CSSComputedStyleDeclaration(elt);
+    // FIXME: This needs take pseudo elements into account.
+    return computedStyle(elt);
 }
 
 PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* elt, const String& pseudoElt, bool authorOnly) const
index d4f1954e113580de1e6e1751c6c5fe9f41c6ad74..3c3b0dfa78547dfa5c87746bd00c6dce49dfa076 100644 (file)
@@ -866,9 +866,8 @@ void Frame::computeAndSetTypingStyle(CSSStyleDeclaration *style, EditAction edit
         mutableStyle = typingStyle();
     }
 
-    Node *node = selection()->selection().visibleStart().deepEquivalent().node();
-    CSSComputedStyleDeclaration computedStyle(node);
-    computedStyle.diff(mutableStyle.get());
+    Node* node = selection()->selection().visibleStart().deepEquivalent().node();
+    computedStyle(node)->diff(mutableStyle.get());
     
     // Handle block styles, substracting these from the typing style.
     RefPtr<CSSMutableStyleDeclaration> blockStyle = mutableStyle->copyBlockProperties();
@@ -898,7 +897,7 @@ String Frame::selectionStartStylePropertyValue(int stylePropertyID) const
     return value;
 }
 
-CSSComputedStyleDeclaration *Frame::selectionComputedStyle(Node *&nodeToRemove) const
+PassRefPtr<CSSComputedStyleDeclaration> Frame::selectionComputedStyle(Node*& nodeToRemove) const
 {
     nodeToRemove = 0;
 
@@ -945,7 +944,7 @@ CSSComputedStyleDeclaration *Frame::selectionComputedStyle(Node *&nodeToRemove)
         nodeToRemove = styleElement.get();
     }
 
-    return new CSSComputedStyleDeclaration(styleElement);
+    return computedStyle(styleElement.release());
 }
 
 void Frame::textFieldDidBeginEditing(Element* e)
index f00d589ad6bf3592d0247268dbdd469e40622981..7de78129dda1d49e7c4d565960e2af73f5161837 100644 (file)
@@ -264,7 +264,7 @@ public:
     bool markedTextMatchesAreHighlighted() const;
     void setMarkedTextMatchesAreHighlighted(bool flag);
 
-    CSSComputedStyleDeclaration* selectionComputedStyle(Node*& nodeToRemove) const;
+    PassRefPtr<CSSComputedStyleDeclaration> selectionComputedStyle(Node*& nodeToRemove) const;
 
     void textFieldDidBeginEditing(Element*);
     void textFieldDidEndEditing(Element*);
index 0a6dad779014790b073462658c5a8f32ca03e48f..0213a29d1bc2a9eac91622291246dd211955e8cc 100644 (file)
@@ -130,7 +130,7 @@ StyleVisualData::StyleVisualData(const StyleVisualData& o)
 
 PassRefPtr<CSSValue> StyleCachedImage::cssValue()
 {
-    return new CSSPrimitiveValue(m_image->url(), CSSPrimitiveValue::CSS_URI);
+    return CSSPrimitiveValue::create(m_image->url(), CSSPrimitiveValue::CSS_URI);
 }
 
 bool StyleCachedImage::canRender(float multiplier) const
index cb8899b461816542d116e150fa496c9027e12a4a..ce69b11a70a78503ef4afeecf2e9f8888c423df7 100644 (file)
@@ -39,7 +39,6 @@
 #include "CSSImageGeneratorValue.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSReflectionDirection.h"
-#include "CSSTransformValue.h"
 #include "CSSValueList.h"
 #include "Color.h"
 #include "DataRef.h"
index 12e97399883e03a1091ef43d5638baba87f4d73f..b56a80e030751c77107aa407a14337782930d03d 100644 (file)
 namespace WebCore {
 
 SVGColor::SVGColor()
-    : CSSValue()
-    , m_colorType(SVG_COLORTYPE_UNKNOWN)
+    : m_colorType(SVG_COLORTYPE_UNKNOWN)
 {
 }
 
 SVGColor::SVGColor(const String& rgbColor)
-    : CSSValue()
-    , m_colorType(SVG_COLORTYPE_RGBCOLOR)
+    : m_colorType(SVG_COLORTYPE_RGBCOLOR)
 {
     setRGBColor(rgbColor);
 }
 
-SVGColor::SVGColor(unsigned short colorType)
-    : CSSValue()
-    , m_colorType(colorType)
+SVGColor::SVGColor(SVGColorType colorType)
+    : m_colorType(colorType)
 {
 }
 
 SVGColor::SVGColor(const Color& c)
-    : CSSValue()
-    , m_color(c)
+    : m_color(c)
     , m_colorType(SVG_COLORTYPE_RGBCOLOR)
 {
 }
index 213b2bc963fa886f9c18b082c1df6c0e23ce13b1..e3a4b1936ffae62c3e1ea5d6bcaeefe7e74e6fb1 100644 (file)
@@ -2,8 +2,6 @@
     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
 
-    This file is part of the KDE project
-
     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
 
 #include "CSSValue.h"
 #include "Color.h"
-#include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
-   
-    typedef int ExceptionCode;
+
     class SVGColor : public CSSValue {
     public:
-        SVGColor();
-        SVGColor(const String& rgbColor);
-        SVGColor(const Color& c);
-        SVGColor(unsigned short colorType);
+        static PassRefPtr<SVGColor> create(const String& color)
+        {
+            return adoptRef(new SVGColor(color));
+        }
+        static PassRefPtr<SVGColor> create(const Color& color)
+        {
+            return adoptRef(new SVGColor(color));
+        }
+        static PassRefPtr<SVGColor> createCurrentColor()
+        {
+            return adoptRef(new SVGColor(SVG_COLORTYPE_CURRENTCOLOR));
+        }
+
         virtual ~SVGColor();
 
         enum SVGColorType {
@@ -64,9 +69,18 @@ namespace WebCore {
         // Helpers
         const Color& color() const;
 
-        virtual bool isSVGColor() const { return true; }
+    protected:
+        SVGColor();
+        SVGColor(const String& color);
+        SVGColor(const Color&);
 
     private:
+        SVGColor(SVGColorType);
+
+        static void create(int); // compile-time guard 
+
+        virtual bool isSVGColor() const { return true; }
+
         Color m_color;
         unsigned short m_colorType;
     };
index 2ac6d368e1d65a4b2ec745a795a60ed4486e0285..c4509844cda9469fc491ea35d58c77a999c01ffc 100644 (file)
@@ -48,8 +48,8 @@ using namespace SVGNames;
 
 SVGFontFaceElement::SVGFontFaceElement(const QualifiedName& tagName, Document* doc)
     : SVGElement(tagName, doc)
-    , m_fontFaceRule(new CSSFontFaceRule(0))
-    , m_styleDeclaration(new CSSMutableStyleDeclaration)
+    , m_fontFaceRule(CSSFontFaceRule::create())
+    , m_styleDeclaration(CSSMutableStyleDeclaration::create())
 {
     m_styleDeclaration->setParent(document()->mappedElementSheet());
     m_styleDeclaration->setStrictParsing(true);
@@ -318,8 +318,8 @@ void SVGFontFaceElement::rebuildFontFace()
     if (describesParentFont) {
         m_fontElement = static_cast<SVGFontElement*>(parentNode());
 
-        list = new CSSValueList;
-        list->append(new CSSFontFaceSrcValue(fontFamily(), true));
+        list = CSSValueList::createCommaSeparated();
+        list->append(CSSFontFaceSrcValue::createLocal(fontFamily()));
     } else if (srcElement)
         list = srcElement->srcValue();
 
index 182580265103df28d2a5905dabba264562c7f42e..91002e1e9d53aa0be854b3e48a5022d2aa64e8d1 100644 (file)
@@ -34,7 +34,7 @@ SVGFontFaceNameElement::SVGFontFaceNameElement(const QualifiedName& tagName, Doc
 
 PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceNameElement::srcValue() const
 {
-    return new CSSFontFaceSrcValue(getAttribute(SVGNames::nameAttr), true);
+    return CSSFontFaceSrcValue::createLocal(getAttribute(SVGNames::nameAttr));
 }
 
 }
index 5762cd9ef5d90b820f07e1903b679852a7b0ac99..0d72c746320b26feaaa7b10b824d1c2eb6039ad5 100644 (file)
@@ -40,7 +40,7 @@ SVGFontFaceSrcElement::SVGFontFaceSrcElement(const QualifiedName& tagName, Docum
 
 PassRefPtr<CSSValueList> SVGFontFaceSrcElement::srcValue() const
 {
-    RefPtr<CSSValueList> list = new CSSValueList;
+    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     for (Node* child = firstChild(); child; child = child->nextSibling()) {
         if (child->hasTagName(font_face_uriTag))
             list->append(static_cast<SVGFontFaceUriElement*>(child)->srcValue());
index 2f4b99fd2e6d69c5aaf6fd4781f404efe4a8b21c..7f6c6d25d2597e082807b8838da3b64c1e2261f9 100644 (file)
@@ -38,7 +38,7 @@ SVGFontFaceUriElement::SVGFontFaceUriElement(const QualifiedName& tagName, Docum
 
 PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const
 {
-    RefPtr<CSSFontFaceSrcValue> src = new CSSFontFaceSrcValue(getAttribute(XLinkNames::hrefAttr), false);
+    RefPtr<CSSFontFaceSrcValue> src = CSSFontFaceSrcValue::create(getAttribute(XLinkNames::hrefAttr));
     AtomicString value(getAttribute(formatAttr));
     src->setFormat(value.isEmpty() ? "svg" : value); // Default format
     return src.release();
index bd27a57b1f6451c4a72e13284146f7598ea20ee1..45abe69ae23f84ee3423e6c9368d003e448bee54 100644 (file)
 namespace WebCore {
 
 SVGPaint::SVGPaint()
-    : SVGColor()
-    , m_paintType(SVG_PAINTTYPE_UNKNOWN)
+    : m_paintType(SVG_PAINTTYPE_UNKNOWN)
 {
 }
 
 SVGPaint::SVGPaint(const String& uri)
-    : SVGColor()
-    , m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
+    : m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
 {
     setUri(uri);
 }
 
 SVGPaint::SVGPaint(SVGPaintType paintType)
-    : SVGColor()
-    , m_paintType(paintType)
+    : m_paintType(paintType)
 {
 }
 
index e434eaeb81f36e95ebfaf725cce97f22236ff93e..032f7157641dfcda82c19538cbded13521200f2c 100644 (file)
@@ -3,8 +3,6 @@
                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
     Copyright (C) 2006 Samuel Weinig (sam.weinig@gmial.com)
 
-    This file is part of the KDE project
-
     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
@@ -26,6 +24,7 @@
 #if ENABLE(SVG)
 
 #include "SVGColor.h"
+#include "PlatformString.h"
 
 namespace WebCore {
 
@@ -44,12 +43,27 @@ namespace WebCore {
             SVG_PAINTTYPE_URI                   = 107
         };
 
-        SVGPaint();
-        SVGPaint(const String& uri);
-        SVGPaint(SVGPaintType);
-        SVGPaint(SVGPaintType, const String& uri, const String& rgbPaint = String(), const String& iccPaint = String());
-        SVGPaint(const Color& c);
-        SVGPaint(const String& uri, const Color& c);
+        static PassRefPtr<SVGPaint> create()
+        {
+            return adoptRef(new SVGPaint);
+        }
+        static PassRefPtr<SVGPaint> create(SVGPaintType type)
+        {
+            return adoptRef(new SVGPaint(type));
+        }
+        static PassRefPtr<SVGPaint> create(const Color& color)
+        {
+            return adoptRef(new SVGPaint(color));
+        }
+        static PassRefPtr<SVGPaint> create(SVGPaintType type, const String& uri)
+        {
+            return adoptRef(new SVGPaint(type, uri, String(), String()));
+        }
+        static PassRefPtr<SVGPaint> create(const String& uri, const Color& color)
+        {
+            return adoptRef(new SVGPaint(uri, color));
+        }
+
         virtual ~SVGPaint();
 
         // 'SVGPaint' functions
@@ -64,8 +78,16 @@ namespace WebCore {
         static SVGPaint* defaultFill();
         static SVGPaint* defaultStroke();
 
-        virtual bool isSVGPaint() const { return true; }
     private:
+        SVGPaint();
+        SVGPaint(const String& uri);
+        SVGPaint(SVGPaintType);
+        SVGPaint(SVGPaintType, const String& uri, const String& rgbPaint, const String& iccPaint);
+        SVGPaint(const Color& c);
+        SVGPaint(const String& uri, const Color& c);
+
+        virtual bool isSVGPaint() const { return true; }
+
         SVGPaintType m_paintType;
         String m_uri;
     };
index 95d37041c558f319a4c97b6b33148186e3246cb6..02283d6e377af9db13e97d8b4ef07110a2149657 100644 (file)
@@ -198,10 +198,9 @@ String SMILTimeContainer::baseValueFor(ElementAttributePair key)
     ASSERT(target);
     ASSERT(!attributeName.isEmpty());
     String baseValue;
-    if (SVGAnimationElement::attributeIsCSS(attributeName)) {
-        CSSComputedStyleDeclaration computedStyle(target);
-        baseValue = computedStyle.getPropertyValue(cssPropertyID(attributeName));
-    } else
+    if (SVGAnimationElement::attributeIsCSS(attributeName))
+        baseValue = computedStyle(target)->getPropertyValue(cssPropertyID(attributeName));
+    else
         baseValue = target->getAttribute(attributeName);
     m_savedBaseValues.add(key, baseValue);
     return baseValue;
index 52c257b46283f2e9c398d0a2dfc0d72ab98eda14..2efafa38c5ba7331ff87176d70ffc521a6dae58a 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-XSLImportRule::XSLImportRule(StyleBase* parent, const String& href)
+XSLImportRule::XSLImportRule(XSLStyleSheet* parent, const String& href)
     : StyleBase(parent)
     , m_strHref(href)
     , m_cachedSheet(0)
@@ -57,7 +57,7 @@ void XSLImportRule::setXSLStyleSheet(const String& url, const String& sheet)
     if (m_styleSheet)
         m_styleSheet->setParent(0);
     
-    m_styleSheet = new XSLStyleSheet(this, url);
+    m_styleSheet = XSLStyleSheet::create(this, url);
     
     XSLStyleSheet* parent = parentStyleSheet();
     if (parent)
index e4bbc4bb1344771b28627c3d7cf2bdbdbbc6d64b..68df34b0fd4298cd6c65032571dacaf0b5fb1639 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the XSL implementation.
  *
- * Copyright (C) 2004, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -33,24 +33,31 @@ namespace WebCore {
 
 class CachedXSLStyleSheet;
 
-class XSLImportRule : public CachedResourceClient, public StyleBase {
+class XSLImportRule : public StyleBase, private CachedResourceClient {
 public:
-    XSLImportRule(StyleBase* parent, const String& href);
+    static PassRefPtr<XSLImportRule> create(XSLStyleSheet* parentSheet, const String& href)
+    {
+        return adoptRef(new XSLImportRule(parentSheet, href));
+    }
+
     virtual ~XSLImportRule();
     
-    String href() const { return m_strHref; }
+    const String& href() const { return m_strHref; }
     XSLStyleSheet* styleSheet() const { return m_styleSheet.get(); }
-    
-    virtual bool isImportRule() { return true; }
+
     XSLStyleSheet* parentStyleSheet() const;
+
+    bool isLoading();
+    void loadSheet();
     
+private:
+    XSLImportRule(XSLStyleSheet* parentSheet, const String& href);
+
+    virtual bool isImportRule() { return true; }
+
     // from CachedResourceClient
     virtual void setXSLStyleSheet(const String& url, const String& sheet);
     
-    bool isLoading();
-    void loadSheet();
-    
-protected:
     String m_strHref;
     RefPtr<XSLStyleSheet> m_styleSheet;
     CachedXSLStyleSheet* m_cachedSheet;
index c9153665bcd446f13683ba4cd2c6bdde931a3c3f..9443652458bebf8581933d1c3dc0e305e3e474f3 100644 (file)
@@ -99,8 +99,8 @@ void XSLStyleSheet::checkLoaded()
         return;
     if (parent())
         parent()->checkLoaded();
-    if (m_parentNode)
-        m_parentNode->sheetLoaded();
+    if (ownerNode())
+        ownerNode()->sheetLoaded();
 }
 
 xmlDocPtr XSLStyleSheet::document()
@@ -215,7 +215,7 @@ void XSLStyleSheet::loadChildSheets()
 
 void XSLStyleSheet::loadChildSheet(const String& href)
 {
-    RefPtr<XSLImportRule> childRule = new XSLImportRule(this, href);
+    RefPtr<XSLImportRule> childRule = XSLImportRule::create(this, href);
     append(childRule);
     childRule->loadSheet();
 }
index 0509cc07e63da874ea8ffb71b80c649ea072398b..8946529aef2bacc35570eab7d224e28b8334f582 100644 (file)
@@ -28,6 +28,7 @@
 #include "StyleSheet.h"
 #include <libxml/parser.h>
 #include <libxslt/transform.h>
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
@@ -37,9 +38,20 @@ class XSLImportRule;
     
 class XSLStyleSheet : public StyleSheet {
 public:
-    XSLStyleSheet(Node* parentNode, const String& href = String(), bool embedded = false);
-    XSLStyleSheet(XSLImportRule* parentImport, const String& href = String());
-    ~XSLStyleSheet();
+    static PassRefPtr<XSLStyleSheet> create(XSLImportRule* parentImport, const String& href)
+    {
+        return adoptRef(new XSLStyleSheet(parentImport, href));
+    }
+    static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& href)
+    {
+        return adoptRef(new XSLStyleSheet(parentNode, href, false));
+    }
+    static PassRefPtr<XSLStyleSheet> createEmbedded(Node* parentNode, const String& href)
+    {
+        return adoptRef(new XSLStyleSheet(parentNode, href, true));
+    }
+
+    virtual ~XSLStyleSheet();
     
     virtual bool isXSLStyleSheet() const { return true; }
 
@@ -69,7 +81,10 @@ public:
     void markAsProcessed();
     bool processed() const { return m_processed; }
 
-protected:
+private:
+    XSLStyleSheet(Node* parentNode, const String& href, bool embedded);
+    XSLStyleSheet(XSLImportRule* parentImport, const String& href);
+
     Document* m_ownerDocument;
     xmlDocPtr m_stylesheetDoc;
     bool m_embedded;
index 8117e863d6a276228312ecfda1d266afeed20e00..1ae8d83a1d79ffe342533cb5b20e3e31c9daf727 100644 (file)
@@ -300,7 +300,7 @@ static inline RefPtr<DocumentFragment> createFragmentFromSource(const String& so
 static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet>& cachedStylesheet, Node* stylesheetRootNode)
 {
     if (!cachedStylesheet && stylesheetRootNode) {
-        cachedStylesheet = new XSLStyleSheet(stylesheetRootNode->parent() ? stylesheetRootNode->parent() : stylesheetRootNode,
+        cachedStylesheet = XSLStyleSheet::create(stylesheetRootNode->parent() ? stylesheetRootNode->parent() : stylesheetRootNode,
             stylesheetRootNode->document()->url().string());
         cachedStylesheet->parseString(createMarkup(stylesheetRootNode));
     }
index 94c2d69da756cca501e65eec42356879a19d2451..39f3c2ec791adf0e93ec393b0f6de86e7f1d3a0d 100644 (file)
@@ -1,3 +1,11 @@
+2008-06-17  Darin Adler  <darin@apple.com>
+
+        Reviewed by Sam.
+
+   &nb