Commit 3b8ced0a authored by darin@apple.com's avatar darin@apple.com

2010-08-29 Darin Adler <darin@apple.com>

        Reviewed by Sam Weinig.

        Deploy OwnPtr, PassOwnPtr, and adoptPtr in some CSS-related files
        https://bugs.webkit.org/show_bug.cgi?id=44834

        * css/CSSFunctionValue.cpp:
        (WebCore::CSSFunctionValue::CSSFunctionValue): Updated since
        CSSParserFunction::args is an OwnPtr.
        (WebCore::CSSFunctionValue::parserValue): Ditto.

        * css/CSSGrammar.y: Added leakPtr calls for putting MediaQueryExp*
        into the media query expression list, which is a vector of raw pointers
        that are deleted explicitly.

        * css/CSSImportRule.cpp:
        (WebCore::CSSImportRule::setCSSStyleSheet): Updated to use document instead of doc.
        (WebCore::CSSImportRule::insertedIntoParent): Ditto.
        * css/CSSMutableStyleDeclaration.cpp:
        (WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc): Ditto.

        * css/CSSNamespace.h: Took the "m_" off the names of the data members of
        this structure. Used OwnPtr for the parent data member. Rewrote the
        namespaceForPrefix function so it's iterative instead of recursive.

        * css/CSSParser.cpp:
        (WebCore::CSSParser::CSSParser): Update since m_mediaQuery, m_floatingMediaQuery,
        m_floatingMediaQueryExp, and m_floatingMediaQueryExpList are now all OwnPtr and
        thus don't need to be initialized.
        (WebCore::CSSParser::~CSSParser): Update to not delete the above OwnPtr.
        (WebCore::CSSParser::parseMediaQuery): Replaced the code that sets m_mediaQuery
        to 0 with an assertion. Also use release when passing the media query to
        appendMediaQuery.
        (WebCore::CSSParser::document): Updated to use document instead of doc and to
        use early return instead of a nested if.
        (WebCore::CSSParser::parseContent): Added a get() call needed since
        CSSParserFunction::args is an OwnPtr.
        (WebCore::CSSParser::parseAnimationTimingFunction): Ditto.
        (WebCore::CSSParser::parseDashboardRegions): Ditto.
        (WebCore::CSSParser::parseShape): Ditto.
        (WebCore::isValidFormatFunction): Ditto.
        (WebCore::CSSParser::parseFontFaceSrc): Ditto.
        (WebCore::CSSParser::parseColorParameters): Ditto.
        (WebCore::CSSParser::parseHSLParameters): Ditto.
        (WebCore::parseGradientColorStop): Ditto.
        (WebCore::CSSParser::parseGradient): Ditto.
        (WebCore::CSSParser::parseCanvas): Ditto.
        (WebCore::CSSParser::parseTransform): Ditto.
        (WebCore::CSSParser::createFloatingMediaQueryExp): Updated to use adoptPtr and
        remove the explicit deletion.
        (WebCore::CSSParser::sinkFloatingMediaQueryExp): Updated to use release.
        (WebCore::CSSParser::createFloatingMediaQueryExpList): Ditto.
        (WebCore::CSSParser::sinkFloatingMediaQueryExpList): Ditto.
        (WebCore::CSSParser::createFloatingMediaQuery): Ditto.
        (WebCore::CSSParser::sinkFloatingMediaQuery): Ditto.
        (WebCore::CSSParser::checkForVariables): Use get for CSSParserFunction::args.

        * css/CSSParser.h: Made return values for sinkFloatingMediaQueryExp,
        sinkFloatingMediaQueryExpList, and sinkFloatingMediaQuery be PassOwnPtr.
        Made createFloatingMediaQuery take a PassOwnPtr. Made m_mediaQuery,
        m_floatingMediaQuery, m_floatingMediaQueryExp, and m_floatingMediaQueryExpList
        be OwnPtr.

        * css/CSSParserValues.h: Made args be an OwnPtr.

        * css/CSSStyleSelector.cpp: Made CSSRuleSet m_universalRules and m_pageRules
        be OwnPtr.
        (WebCore::CSSStyleSelector::CSSStyleSelector): Use document instead of doc.
        Got rid of the init function, only called here, because it did nothing that
        wasn't already done. Eliminated unneeded code to set m_userStyle to 0, since
        it's now an OwnPtr and will be 0 automatically. Use adoptPtr when initializing
        m_medium, m_authorStyle, and m_useStyle.
        (WebCore::CSSStyleSelector::~CSSStyleSelector): Got rid of unneeded delete of
        m_medium, m_authorStyle, and m_userStyle, and unneded clear of m_keyframesRuleMap.
        (WebCore::CSSStyleSelector::styleForElement): Use get with m_userStyle and
        m_authorStyle.
        (WebCore::CSSStyleSelector::pseudoStyleForElement): Ditto.
        (WebCore::CSSStyleSelector::styleForPage): Ditto.
        (WebCore::CSSStyleSelector::pseudoStyleRulesForElement): Ditto.
        (WebCore::CSSRuleSet::CSSRuleSet): Got rid of unneeded initialization of
        m_universalRules and m_pageRules.
        (WebCore::CSSRuleSet::~CSSRuleSet): Got rid of unneeed deletion of same.
        (WebCore::CSSRuleSet::addRule): Use adoptPtr to initialize m_universalRules.
        (WebCore::CSSRuleSet::addPageRule): Use adoptPtr to initialize m_pageRules.
        (WebCore::CSSStyleSelector::applyProperty): Use adopPtr to create counter
        context object.

        * css/CSSStyleSelector.h: Made m_authorStyle, m_userStyle, and m_medium use
        OwnPtr. Got rid of init function.

        * css/CSSStyleSheet.cpp:
        (WebCore::CSSStyleSheet::CSSStyleSheet): Updatd for name change from m_doc
        and doc to m_document and document. Eliminated unneeded initialization of
        m_namespaces now that it is an OwnPtr.
        (WebCore::CSSStyleSheet::~CSSStyleSheet): Got rid of unneeded deletion of same.
        (WebCore::CSSStyleSheet::cssRules): Updated doc to document.
        (WebCore::CSSStyleSheet::addNamespace): Added adopPtr when setting m_namespaces.
        (WebCore::CSSStyleSheet::determineNamespace): Updated for changes to the
        CSSNamespace class, using uri data member instead of function.
        (WebCore::CSSStyleSheet::styleSheetChanged): Use document instead of doc.

        * css/CSSStyleSheet.h: Renamed doc and m_doc to document and m_document.
        Made m_namespaces an OwnPtr.

        * css/CSSValueList.cpp:
        (WebCore::CSSValueList::CSSValueList): Clean up logic a bit.
        (WebCore::CSSValueList::createParserValueList): Clean up logic a bit and
        return a PassOwnPtr.

        * css/CSSValueList.h: Changed createParserValueList to return a PassOwnPtr.

        * css/CSSVariablesDeclaration.cpp:
        (WebCore::CSSVariablesDeclaration::setNeedsStyleRecalc): Updated to use
        document instead of doc.

        * css/MediaList.cpp:
        (WebCore::MediaList::deleteMedium): Use OwnPtr instead of a boolean to
        make sure the newly-created query here is deleted.
        (WebCore::MediaList::appendMediaQuery): Updated to take PassOwnPtr.

        * css/MediaList.h: Changed appendMediaQuery to take a PassOwnPtr.

        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::getStyleSheet): Use document instead of doc.
        (WebCore::InspectorDOMAgent::getRuleRanges): Ditto.
        (WebCore::InspectorDOMAgent::buildObjectForStyleSheet): Ditto.

        * rendering/style/ContentData.cpp:
        (WebCore::ContentData::clear): Update since data members are OwnPtr.
        Also, fixed iterative deletion algorithm to be much simpler.
        (WebCore::ContentData::dataEquivalent): Added FIXMEs and tweaked formatting.
        (WebCore::ContentData::deleteContent): Tweaked formatting.

        * rendering/style/ContentData.h: Changed m_next to an OwnPtr.
        Added assertions to getters to check that we get the correct type.
        Use leakRef instead of releaseRef. Changed setCounter and setNext functions
        to take PassOwnPtr arguments.

        * rendering/style/RenderStyle.cpp:
        (WebCore::RenderStyle::prepareToSetContent): Refactored common part of the
        into a shared function so the three setContent functions don't have to repeat
        the logic. Used an OwnPtr to avoid confusing logic and leakPtr.
        (WebCore::RenderStyle::setContent): Changed argument to PassOwnPtr.

        * rendering/style/RenderStyle.h: Changed setContent argument to a PassOwnPtr.
        Added declaration of prepareToSetContent helper function.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66334 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 46de86f9
2010-08-29 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
Deploy OwnPtr, PassOwnPtr, and adoptPtr in some CSS-related files
https://bugs.webkit.org/show_bug.cgi?id=44834
* css/CSSFunctionValue.cpp:
(WebCore::CSSFunctionValue::CSSFunctionValue): Updated since
CSSParserFunction::args is an OwnPtr.
(WebCore::CSSFunctionValue::parserValue): Ditto.
* css/CSSGrammar.y: Added leakPtr calls for putting MediaQueryExp*
into the media query expression list, which is a vector of raw pointers
that are deleted explicitly.
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::setCSSStyleSheet): Updated to use document instead of doc.
(WebCore::CSSImportRule::insertedIntoParent): Ditto.
* css/CSSMutableStyleDeclaration.cpp:
(WebCore::CSSMutableStyleDeclaration::setNeedsStyleRecalc): Ditto.
* css/CSSNamespace.h: Took the "m_" off the names of the data members of
this structure. Used OwnPtr for the parent data member. Rewrote the
namespaceForPrefix function so it's iterative instead of recursive.
* css/CSSParser.cpp:
(WebCore::CSSParser::CSSParser): Update since m_mediaQuery, m_floatingMediaQuery,
m_floatingMediaQueryExp, and m_floatingMediaQueryExpList are now all OwnPtr and
thus don't need to be initialized.
(WebCore::CSSParser::~CSSParser): Update to not delete the above OwnPtr.
(WebCore::CSSParser::parseMediaQuery): Replaced the code that sets m_mediaQuery
to 0 with an assertion. Also use release when passing the media query to
appendMediaQuery.
(WebCore::CSSParser::document): Updated to use document instead of doc and to
use early return instead of a nested if.
(WebCore::CSSParser::parseContent): Added a get() call needed since
CSSParserFunction::args is an OwnPtr.
(WebCore::CSSParser::parseAnimationTimingFunction): Ditto.
(WebCore::CSSParser::parseDashboardRegions): Ditto.
(WebCore::CSSParser::parseShape): Ditto.
(WebCore::isValidFormatFunction): Ditto.
(WebCore::CSSParser::parseFontFaceSrc): Ditto.
(WebCore::CSSParser::parseColorParameters): Ditto.
(WebCore::CSSParser::parseHSLParameters): Ditto.
(WebCore::parseGradientColorStop): Ditto.
(WebCore::CSSParser::parseGradient): Ditto.
(WebCore::CSSParser::parseCanvas): Ditto.
(WebCore::CSSParser::parseTransform): Ditto.
(WebCore::CSSParser::createFloatingMediaQueryExp): Updated to use adoptPtr and
remove the explicit deletion.
(WebCore::CSSParser::sinkFloatingMediaQueryExp): Updated to use release.
(WebCore::CSSParser::createFloatingMediaQueryExpList): Ditto.
(WebCore::CSSParser::sinkFloatingMediaQueryExpList): Ditto.
(WebCore::CSSParser::createFloatingMediaQuery): Ditto.
(WebCore::CSSParser::sinkFloatingMediaQuery): Ditto.
(WebCore::CSSParser::checkForVariables): Use get for CSSParserFunction::args.
* css/CSSParser.h: Made return values for sinkFloatingMediaQueryExp,
sinkFloatingMediaQueryExpList, and sinkFloatingMediaQuery be PassOwnPtr.
Made createFloatingMediaQuery take a PassOwnPtr. Made m_mediaQuery,
m_floatingMediaQuery, m_floatingMediaQueryExp, and m_floatingMediaQueryExpList
be OwnPtr.
* css/CSSParserValues.h: Made args be an OwnPtr.
* css/CSSStyleSelector.cpp: Made CSSRuleSet m_universalRules and m_pageRules
be OwnPtr.
(WebCore::CSSStyleSelector::CSSStyleSelector): Use document instead of doc.
Got rid of the init function, only called here, because it did nothing that
wasn't already done. Eliminated unneeded code to set m_userStyle to 0, since
it's now an OwnPtr and will be 0 automatically. Use adoptPtr when initializing
m_medium, m_authorStyle, and m_useStyle.
(WebCore::CSSStyleSelector::~CSSStyleSelector): Got rid of unneeded delete of
m_medium, m_authorStyle, and m_userStyle, and unneded clear of m_keyframesRuleMap.
(WebCore::CSSStyleSelector::styleForElement): Use get with m_userStyle and
m_authorStyle.
(WebCore::CSSStyleSelector::pseudoStyleForElement): Ditto.
(WebCore::CSSStyleSelector::styleForPage): Ditto.
(WebCore::CSSStyleSelector::pseudoStyleRulesForElement): Ditto.
(WebCore::CSSRuleSet::CSSRuleSet): Got rid of unneeded initialization of
m_universalRules and m_pageRules.
(WebCore::CSSRuleSet::~CSSRuleSet): Got rid of unneeed deletion of same.
(WebCore::CSSRuleSet::addRule): Use adoptPtr to initialize m_universalRules.
(WebCore::CSSRuleSet::addPageRule): Use adoptPtr to initialize m_pageRules.
(WebCore::CSSStyleSelector::applyProperty): Use adopPtr to create counter
context object.
* css/CSSStyleSelector.h: Made m_authorStyle, m_userStyle, and m_medium use
OwnPtr. Got rid of init function.
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet): Updatd for name change from m_doc
and doc to m_document and document. Eliminated unneeded initialization of
m_namespaces now that it is an OwnPtr.
(WebCore::CSSStyleSheet::~CSSStyleSheet): Got rid of unneeded deletion of same.
(WebCore::CSSStyleSheet::cssRules): Updated doc to document.
(WebCore::CSSStyleSheet::addNamespace): Added adopPtr when setting m_namespaces.
(WebCore::CSSStyleSheet::determineNamespace): Updated for changes to the
CSSNamespace class, using uri data member instead of function.
(WebCore::CSSStyleSheet::styleSheetChanged): Use document instead of doc.
* css/CSSStyleSheet.h: Renamed doc and m_doc to document and m_document.
Made m_namespaces an OwnPtr.
* css/CSSValueList.cpp:
(WebCore::CSSValueList::CSSValueList): Clean up logic a bit.
(WebCore::CSSValueList::createParserValueList): Clean up logic a bit and
return a PassOwnPtr.
* css/CSSValueList.h: Changed createParserValueList to return a PassOwnPtr.
* css/CSSVariablesDeclaration.cpp:
(WebCore::CSSVariablesDeclaration::setNeedsStyleRecalc): Updated to use
document instead of doc.
* css/MediaList.cpp:
(WebCore::MediaList::deleteMedium): Use OwnPtr instead of a boolean to
make sure the newly-created query here is deleted.
(WebCore::MediaList::appendMediaQuery): Updated to take PassOwnPtr.
* css/MediaList.h: Changed appendMediaQuery to take a PassOwnPtr.
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::getStyleSheet): Use document instead of doc.
(WebCore::InspectorDOMAgent::getRuleRanges): Ditto.
(WebCore::InspectorDOMAgent::buildObjectForStyleSheet): Ditto.
* rendering/style/ContentData.cpp:
(WebCore::ContentData::clear): Update since data members are OwnPtr.
Also, fixed iterative deletion algorithm to be much simpler.
(WebCore::ContentData::dataEquivalent): Added FIXMEs and tweaked formatting.
(WebCore::ContentData::deleteContent): Tweaked formatting.
* rendering/style/ContentData.h: Changed m_next to an OwnPtr.
Added assertions to getters to check that we get the correct type.
Use leakRef instead of releaseRef. Changed setCounter and setNext functions
to take PassOwnPtr arguments.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::prepareToSetContent): Refactored common part of the
into a shared function so the three setContent functions don't have to repeat
the logic. Used an OwnPtr to avoid confusing logic and leakPtr.
(WebCore::RenderStyle::setContent): Changed argument to PassOwnPtr.
* rendering/style/RenderStyle.h: Changed setContent argument to a PassOwnPtr.
Added declaration of prepareToSetContent helper function.
2010-08-29 Patrick Gansterer <paroga@paroga.com>
Reviewed by Adam Roben.
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
* Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,15 +25,17 @@
#include "config.h"
#include "CSSFunctionValue.h"
#include "CSSValueList.h"
#include <wtf/PassOwnPtr.h>
namespace WebCore {
CSSFunctionValue::CSSFunctionValue(CSSParserFunction* function)
: m_name(function->name)
{
m_name = function->name;
if (function->args)
m_args = CSSValueList::createFromParserValueList(function->args);
m_args = CSSValueList::createFromParserValueList(function->args.get());
}
CSSFunctionValue::~CSSFunctionValue()
......@@ -58,7 +60,8 @@ CSSParserValue CSSFunctionValue::parserValue() const
val.function = new CSSParserFunction;
val.function->name.characters = const_cast<UChar*>(m_name.characters());
val.function->name.length = m_name.length();
val.function->args = m_args ? m_args->createParserValueList() : 0;
if (m_args)
val.function->args = m_args->createParserValueList();
return val;
}
......
......@@ -2,7 +2,7 @@
/*
* Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
* Copyright (C) 2008 Eric Seidel <eric@webkit.org>
*
......@@ -34,6 +34,7 @@
#include "Document.h"
#include "HTMLNames.h"
#include "MediaList.h"
#include "MediaQueryExp.h"
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
#include <wtf/FastMalloc.h>
......@@ -617,11 +618,11 @@ media_query_exp_list:
media_query_exp {
CSSParser* p = static_cast<CSSParser*>(parser);
$$ = p->createFloatingMediaQueryExpList();
$$->append(p->sinkFloatingMediaQueryExp($1));
$$->append(p->sinkFloatingMediaQueryExp($1).leakPtr());
}
| media_query_exp_list maybe_space MEDIA_AND maybe_space media_query_exp {
$$ = $1;
$$->append(static_cast<CSSParser*>(parser)->sinkFloatingMediaQueryExp($5));
$$->append(static_cast<CSSParser*>(parser)->sinkFloatingMediaQueryExp($5).leakPtr());
}
;
......
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2002-2003 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2002, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2002, 2005, 2006, 2008, 2009, 2010 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
......@@ -65,7 +65,7 @@ void CSSImportRule::setCSSStyleSheet(const String& href, const KURL& baseURL, co
CSSStyleSheet* parent = parentStyleSheet();
bool strict = !parent || parent->useStrictParsing();
bool enforceMIMEType = strict;
bool needsSiteSpecificQuirks = parent && parent->doc() && parent->doc()->settings() && parent->doc()->settings()->needsSiteSpecificQuirks();
bool needsSiteSpecificQuirks = parent && parent->document() && parent->document()->settings() && parent->document()->settings()->needsSiteSpecificQuirks();
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
if (enforceMIMEType && needsSiteSpecificQuirks) {
......@@ -78,7 +78,7 @@ void CSSImportRule::setCSSStyleSheet(const String& href, const KURL& baseURL, co
String sheetText = sheet->sheetText(enforceMIMEType, &validMIMEType);
m_styleSheet->parseString(sheetText, strict);
if (!parent || !parent->doc() || !parent->doc()->securityOrigin()->canRequest(baseURL))
if (!parent || !parent->document() || !parent->document()->securityOrigin()->canRequest(baseURL))
crossOriginCSS = true;
if (crossOriginCSS && !validMIMEType && !m_styleSheet->hasSyntacticallyValidCSSHeader())
......@@ -115,7 +115,7 @@ void CSSImportRule::insertedIntoParent()
if (!parentSheet)
return;
DocLoader* docLoader = parentSheet->doc()->docLoader();
DocLoader* docLoader = parentSheet->document()->docLoader();
if (!docLoader)
return;
......@@ -143,7 +143,7 @@ void CSSImportRule::insertedIntoParent()
// removed from the pending sheet count, so let the doc know
// the sheet being imported is pending.
if (parentSheet && parentSheet->loadCompleted() && root == parentSheet)
parentSheet->doc()->addPendingSheet();
parentSheet->document()->addPendingSheet();
m_loading = true;
m_cachedSheet->addClient(this);
}
......
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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
......@@ -488,9 +488,10 @@ void CSSMutableStyleDeclaration::setNeedsStyleRecalc()
StyleBase* root = this;
while (StyleBase* parent = root->parent())
root = parent;
if (root->isCSSStyleSheet())
if (Document* doc = static_cast<CSSStyleSheet*>(root)->doc())
doc->styleSelectorChanged(DeferRecalcStyle);
if (root->isCSSStyleSheet()) {
if (Document* document = static_cast<CSSStyleSheet*>(root)->document())
document->styleSelectorChanged(DeferRecalcStyle);
}
}
bool CSSMutableStyleDeclaration::getPropertyPriority(int propertyID) const
......
/*
* 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, 2010 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
......@@ -27,27 +27,23 @@
namespace WebCore {
struct CSSNamespace : Noncopyable {
AtomicString m_prefix;
AtomicString m_uri;
CSSNamespace* m_parent;
CSSNamespace(const AtomicString& prefix, const AtomicString& uri, CSSNamespace* parent)
: m_prefix(prefix)
, m_uri(uri)
, m_parent(parent)
AtomicString prefix;
AtomicString uri;
OwnPtr<CSSNamespace> parent;
CSSNamespace(const AtomicString& prefix, const AtomicString& uri, PassOwnPtr<CSSNamespace> parent)
: prefix(prefix)
, uri(uri)
, parent(parent)
{
}
~CSSNamespace() { delete m_parent; }
const AtomicString& uri() { return m_uri; }
const AtomicString& prefix() { return m_prefix; }
CSSNamespace* namespaceForPrefix(const AtomicString& prefix)
{
if (prefix == m_prefix)
return this;
if (m_parent)
return m_parent->namespaceForPrefix(prefix);
for (CSSNamespace* candidate = this; candidate; candidate = candidate->parent.get()) {
if (candidate->prefix == prefix)
return candidate;
}
return 0;
}
};
......
This diff is collapsed.
/*
* Copyright (C) 2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 Eric Seidel <eric@webkit.org>
* Copyright (C) 2009 - 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
*
......@@ -194,12 +194,12 @@ namespace WebCore {
void endDeclarationsForMarginBox();
MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, CSSParserValueList*);
MediaQueryExp* sinkFloatingMediaQueryExp(MediaQueryExp*);
PassOwnPtr<MediaQueryExp> sinkFloatingMediaQueryExp(MediaQueryExp*);
Vector<MediaQueryExp*>* createFloatingMediaQueryExpList();
Vector<MediaQueryExp*>* sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>*);
MediaQuery* createFloatingMediaQuery(MediaQuery::Restrictor, const String&, Vector<MediaQueryExp*>*);
MediaQuery* createFloatingMediaQuery(Vector<MediaQueryExp*>*);
MediaQuery* sinkFloatingMediaQuery(MediaQuery*);
PassOwnPtr<Vector<MediaQueryExp*> > sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>*);
MediaQuery* createFloatingMediaQuery(MediaQuery::Restrictor, const String&, PassOwnPtr<Vector<MediaQueryExp*> >);
MediaQuery* createFloatingMediaQuery(PassOwnPtr<Vector<MediaQueryExp*> >);
PassOwnPtr<MediaQuery> sinkFloatingMediaQuery(MediaQuery*);
void addNamespace(const AtomicString& prefix, const AtomicString& uri);
......@@ -221,7 +221,7 @@ namespace WebCore {
CSSStyleSheet* m_styleSheet;
RefPtr<CSSRule> m_rule;
RefPtr<CSSRule> m_keyframe;
MediaQuery* m_mediaQuery;
OwnPtr<MediaQuery> m_mediaQuery;
CSSParserValueList* m_valueList;
CSSProperty** m_parsedProperties;
CSSSelectorList* m_selectorListForParseSelector;
......@@ -301,9 +301,9 @@ namespace WebCore {
HashSet<CSSParserValueList*> m_floatingValueLists;
HashSet<CSSParserFunction*> m_floatingFunctions;
MediaQuery* m_floatingMediaQuery;
MediaQueryExp* m_floatingMediaQueryExp;
Vector<MediaQueryExp*>* m_floatingMediaQueryExpList;
OwnPtr<MediaQuery> m_floatingMediaQuery;
OwnPtr<MediaQueryExp> m_floatingMediaQueryExp;
OwnPtr<Vector<MediaQueryExp*> > m_floatingMediaQueryExpList;
Vector<CSSSelector*> m_reusableSelectorVector;
......
/*
* Copyright (C) 2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 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
......@@ -90,9 +90,7 @@ private:
struct CSSParserFunction : FastAllocBase {
CSSParserString name;
CSSParserValueList* args;
~CSSParserFunction() { delete args; }
OwnPtr<CSSParserValueList> args;
};
}
......
This diff is collapsed.
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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
......@@ -195,8 +195,8 @@ public:
bool isFirstPage(int pageIndex) const;
String pageName(int pageIndex) const;
CSSRuleSet* m_authorStyle;
CSSRuleSet* m_userStyle;
OwnPtr<CSSRuleSet> m_authorStyle;
OwnPtr<CSSRuleSet> m_userStyle;
bool m_hasUAAppearance;
BorderData m_borderData;
......@@ -235,8 +235,6 @@ public:
private:
static RenderStyle* s_styleNotYetAvailable;
void init();
void matchUARules(int& firstUARule, int& lastUARule);
void updateFont();
void cacheBorderAndBackground();
......@@ -292,7 +290,7 @@ public:
HashSet<int> m_pendingImageProperties; // Hash of CSSPropertyIDs
MediaQueryEvaluator* m_medium;
OwnPtr<MediaQueryEvaluator> m_medium;
RefPtr<RenderStyle> m_rootDefaultStyle;
PseudoId m_dynamicPseudo;
......
......@@ -36,8 +36,7 @@ namespace WebCore {
CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const KURL& baseURL, const String& charset)
: StyleSheet(parentSheet, href, baseURL)
, m_doc(parentSheet ? parentSheet->doc() : 0)
, m_namespaces(0)
, m_document(parentSheet ? parentSheet->document() : 0)
, m_charset(charset)
, m_loadCompleted(false)
, m_strictParsing(!parentSheet || parentSheet->useStrictParsing())
......@@ -48,8 +47,7 @@ CSSStyleSheet::CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, con
CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& baseURL, const String& charset)
: StyleSheet(parentNode, href, baseURL)
, m_doc(parentNode->document())
, m_namespaces(0)
, m_document(parentNode->document())
, m_charset(charset)
, m_loadCompleted(false)
, m_strictParsing(false)
......@@ -60,20 +58,18 @@ CSSStyleSheet::CSSStyleSheet(Node* parentNode, const String& href, const KURL& b
CSSStyleSheet::CSSStyleSheet(CSSRule* ownerRule, const String& href, const KURL& baseURL, const String& charset)
: StyleSheet(ownerRule, href, baseURL)
, m_namespaces(0)
, m_charset(charset)
, m_loadCompleted(false)
, m_strictParsing(!ownerRule || ownerRule->useStrictParsing())
, m_hasSyntacticallyValidCSSHeader(true)
{
CSSStyleSheet* parentSheet = ownerRule ? ownerRule->parentStyleSheet() : 0;
m_doc = parentSheet ? parentSheet->doc() : 0;
m_document = parentSheet ? parentSheet->document() : 0;
m_isUserStyleSheet = parentSheet ? parentSheet->isUserStyleSheet() : false;
}
CSSStyleSheet::~CSSStyleSheet()
{
delete m_namespaces;
}
CSSRule *CSSStyleSheet::ownerRule() const
......@@ -137,7 +133,7 @@ int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio
PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules(bool omitCharsetRules)
{
KURL url = finalURL();
if (!url.isEmpty() && doc() && !doc()->securityOrigin()->canRequest(url))
if (!url.isEmpty() && document() && !document()->securityOrigin()->canRequest(url))
return 0;
return CSSRuleList::create(this, omitCharsetRules);
}
......@@ -159,7 +155,7 @@ void CSSStyleSheet::addNamespace(CSSParser* p, const AtomicString& prefix, const
if (uri.isNull())
return;
m_namespaces = new CSSNamespace(prefix, uri, m_namespaces);
m_namespaces = adoptPtr(new CSSNamespace(prefix, uri, m_namespaces.release()));
if (prefix.isEmpty())
// Set the default namespace on the parser so that selectors that omit namespace info will
......@@ -174,11 +170,10 @@ const AtomicString& CSSStyleSheet::determineNamespace(const AtomicString& prefix
if (prefix == starAtom)
return starAtom; // We'll match any namespace.
if (m_namespaces) {
CSSNamespace* ns = m_namespaces->namespaceForPrefix(prefix);
if (ns)
return ns->uri();
if (CSSNamespace* namespaceForPrefix = m_namespaces->namespaceForPrefix(prefix))
return namespaceForPrefix->uri;
}
return nullAtom; // Assume we wont match any namespaces.
return nullAtom; // Assume we won't match any namespaces.
}
bool CSSStyleSheet::parseString(const String &string, bool strict)
......@@ -224,7 +219,7 @@ void CSSStyleSheet::styleSheetChanged()
StyleBase* root = this;
while (StyleBase* parent = root->parent())
root = parent;
Document* documentToUpdate = root->isCSSStyleSheet() ? static_cast<CSSStyleSheet*>(root)->doc() : 0;
Document* documentToUpdate = root->isCSSStyleSheet() ? static_cast<CSSStyleSheet*>(root)->document() : 0;
/* FIXME: We don't need to do everything updateStyleSelector does,
* basically we just need to recreate the document's selector with the
......
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 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
......@@ -87,7 +87,7 @@ public:
virtual void checkLoaded();
Document* doc() { return m_doc; }
Document* document() { return m_document; }
const String& charset() const { return m_charset; }
......@@ -112,8 +112,8 @@ private:
virtual bool isCSSStyleSheet() const { return true; }
virtual String type() const { return "text/css"; }
Document* m_doc;
CSSNamespace* m_namespaces;
Document* m_document;
OwnPtr<CSSNamespace> m_namespaces;
String m_charset;
bool m_loadCompleted : 1;
bool m_strictParsing : 1;
......
/**
/*
* (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, 2010 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
......@@ -17,11 +17,13 @@
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "CSSValueList.h"
#include "CSSParserValues.h"
#include "PlatformString.h"
#include <wtf/PassOwnPtr.h>
namespace WebCore {
......@@ -34,11 +36,9 @@ CSSValueList::CSSValueList(CSSParserValueList* list)
: m_isSpaceSeparated(true)
{
if (list) {
unsigned s = list->size();
for (unsigned i = 0; i < s; ++i) {
CSSParserValue* v = list->valueAt(i);
append(v->createCSSValue());
}
size_t size = list->size();
for (unsigned i = 0; i < size; ++i)
append(list->valueAt(i)->createCSSValue());
}
}
......@@ -120,15 +120,15 @@ String CSSValueList::cssText() const
return result;
}
CSSParserValueList* CSSValueList::createParserValueList() const
PassOwnPtr<CSSParserValueList> CSSValueList::createParserValueList() const
{
unsigned s = m_values.size();
if (!s)
size_t size = m_values.size();
if (!size)
return 0;
CSSParserValueList* result = new CSSParserValueList;
for (unsigned i = 0; i < s; ++i)
OwnPtr<CSSParserValueList> result = adoptPtr(new CSSParserValueList);
for (size_t i = 0; i < size; ++i)
result->addValue(m_values[i]->parserValue());
return result;
return result.release();
}
void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
......
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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
......@@ -58,7 +58,7 @@ public:
virtual String cssText() const;
CSSParserValueList* createParserValueList() const;
PassOwnPtr<CSSParserValueList> createParserValueList() const;
virtual void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
......
......@@ -169,7 +169,7 @@ void CSSVariablesDeclaration::setNeedsStyleRecalc()
while (StyleBase* parent = root->parent())
root = parent;
if (root->isCSSStyleSheet())
static_cast<CSSStyleSheet*>(root)->doc()->styleSelectorChanged(DeferRecalcStyle);
static_cast<CSSStyleSheet*>(root)->document()->styleSelectorChanged(DeferRecalcStyle);
}
}
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2006 Apple Computer, Inc.
* Copyright (C) 2004, 2006, 2010 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
......@@ -122,7 +122,7 @@ void MediaList::deleteMedium(const String& oldMedium, ExceptionCode& ec)
CSSParser p(true);
MediaQuery* oldQuery = 0;
bool deleteOldQuery = false;
OwnPtr<MediaQuery> createdQuery;
if (p.parseMediaQuery(tempMediaList.get(), oldMedium)) {
if (tempMediaList->m_queries.size() > 0)
......@@ -130,8 +130,8 @@ void MediaList::deleteMedium(const String& oldMedium, ExceptionCode& ec)
} else if (m_fallback) {
String medium = parseMediaDescriptor(oldMedium);
if (!medium.isNull()) {
oldQuery = new MediaQuery(MediaQuery::None, medium, 0);
deleteOldQuery = true;
createdQuery = adoptPtr(new MediaQuery(MediaQuery::None, medium, 0));
oldQuery = createdQuery.get();
}
}
......@@ -148,8 +148,6 @@ void MediaList::deleteMedium(const String& oldMedium, ExceptionCode& ec)
break;
}
}
if (deleteOldQuery)
delete oldQuery;
}
if (!ec)
......@@ -242,9 +240,9 @@ void MediaList::appendMedium(const String& newMedium, ExceptionCode& ec)
notifyChanged();
}
void MediaList::appendMediaQuery(MediaQuery* mediaQuery)
void MediaList::appendMediaQuery(PassOwnPtr<MediaQuery> mediaQuery)
{
m_queries.append(mediaQuery);
m_queries.append(mediaQuery.leakPtr());
}