Changeset 201318 in webkit


Ignore:
Timestamp:
May 23, 2016 10:34:49 PM (8 years ago)
Author:
achristensen@apple.com
Message:

Modernize CSS code
https://bugs.webkit.org/show_bug.cgi?id=157875

Reviewed by Chris Dumez.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation):
(GenerateParametersCheck):

  • bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:

(WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::JSTestObjConstructor::construct):
(WebCore::setJSTestObjPutForwardsNullableAttribute):
(WebCore::jsTestObjPrototypeFunctionMethodWithCallbackArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithCallbackFunctionArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackFunctionArg):
(WebCore::jsTestObjConstructorFunctionStaticMethodWithCallbackArg):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod5):

  • bindings/scripts/test/JS/JSTestTypedefs.cpp:

(WebCore::JSTestTypedefsConstructor::construct):

  • css/CSSBasicShapes.cpp:

(WebCore::serializePositionOffset):
(WebCore::buildSerializablePositionOffset):
(WebCore::CSSBasicShapeCircle::cssText):
(WebCore::CSSBasicShapeEllipse::cssText):

  • css/CSSCalculationValue.cpp:

(WebCore::determineCategory):
(WebCore::CSSCalcExpressionNodeParser::parseValue):

  • css/CSSMediaRule.cpp:

(WebCore::CSSMediaRule::media):

  • css/CSSMediaRule.h:
  • css/CSSOMUtils.h:
  • css/CSSParser.cpp:

(WebCore::CSSParser::createImportRule):
(WebCore::CSSParser::createMediaRule):

  • css/CSSReflectValue.h:
  • css/CSSStyleSheet.cpp:

(WebCore::CSSStyleSheet::setDisabled):
(WebCore::CSSStyleSheet::setMediaQueries):
(WebCore::CSSStyleSheet::insertRule):
(WebCore::CSSStyleSheet::deleteRule):
(WebCore::CSSStyleSheet::isLoading):
(WebCore::CSSStyleSheet::media):
(WebCore::CSSStyleSheet::parentStyleSheet):
(WebCore::CSSStyleSheet::ownerDocument):
(WebCore::CSSStyleSheet::clearChildRuleCSSOMWrappers):
(WebCore::CSSStyleSheet::RuleMutationScope::RuleMutationScope):

  • css/CSSStyleSheet.h:
  • css/PropertySetCSSStyleDeclaration.cpp:
  • css/StyleRule.cpp:

(WebCore::StyleRuleBase::createCSSOMWrapper):
(WebCore::StyleRuleBase::destroy):
(WebCore::StyleRuleGroup::wrapperRemoveRule):
(WebCore::StyleRuleMedia::StyleRuleMedia):

  • css/StyleRule.h:

(WebCore::StyleRuleBase::deref):
(WebCore::StyleRuleBase::StyleRuleBase):
(WebCore::StyleRuleMedia::create):
(WebCore::StyleRuleMedia::mediaQueries):
(WebCore::StyleRuleMedia::copy):
(isType):

  • css/StyleRuleImport.cpp:

(WebCore::StyleRuleImport::create):
(WebCore::StyleRuleImport::StyleRuleImport):

  • css/StyleRuleImport.h:
  • css/StyleSheetContents.cpp:

(WebCore::StyleSheetContents::isCacheable):
(WebCore::StyleSheetContents::parserAppendRule):
(WebCore::StyleSheetContents::ruleAt):
(WebCore::StyleSheetContents::parserSetEncodingFromCharsetRule):
(WebCore::StyleSheetContents::wrapperInsertRule):

  • css/StyleSheetContents.h:

(WebCore::StyleSheetContents::hasSyntacticallyValidCSSHeader):
(WebCore::StyleSheetContents::parserSetUsesRemUnits):
(WebCore::StyleSheetContents::parserSetUsesStyleBasedEditability):
(WebCore::StyleSheetContents::copy):

  • dom/InlineStyleSheetOwner.cpp:

(WebCore::InlineStyleSheetOwner::createSheet):

  • inspector/InspectorStyleSheet.cpp:
Location:
trunk/Source/WebCore
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201312 r201318  
     12016-05-23  Alex Christensen  <achristensen@webkit.org>
     2
     3        Modernize CSS code
     4        https://bugs.webkit.org/show_bug.cgi?id=157875
     5
     6        Reviewed by Chris Dumez.
     7
     8        * bindings/scripts/CodeGeneratorJS.pm:
     9        (GenerateImplementation):
     10        (GenerateParametersCheck):
     11        * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
     12        (WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod):
     13        * bindings/scripts/test/JS/JSTestObj.cpp:
     14        (WebCore::JSTestObjConstructor::construct):
     15        (WebCore::setJSTestObjPutForwardsNullableAttribute):
     16        (WebCore::jsTestObjPrototypeFunctionMethodWithCallbackArg):
     17        (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg):
     18        (WebCore::jsTestObjPrototypeFunctionMethodWithCallbackFunctionArg):
     19        (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackFunctionArg):
     20        (WebCore::jsTestObjConstructorFunctionStaticMethodWithCallbackArg):
     21        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5):
     22        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
     23        (WebCore::JSTestTypedefsConstructor::construct):
     24        * css/CSSBasicShapes.cpp:
     25        (WebCore::serializePositionOffset):
     26        (WebCore::buildSerializablePositionOffset):
     27        (WebCore::CSSBasicShapeCircle::cssText):
     28        (WebCore::CSSBasicShapeEllipse::cssText):
     29        * css/CSSCalculationValue.cpp:
     30        (WebCore::determineCategory):
     31        (WebCore::CSSCalcExpressionNodeParser::parseValue):
     32        * css/CSSMediaRule.cpp:
     33        (WebCore::CSSMediaRule::media):
     34        * css/CSSMediaRule.h:
     35        * css/CSSOMUtils.h:
     36        * css/CSSParser.cpp:
     37        (WebCore::CSSParser::createImportRule):
     38        (WebCore::CSSParser::createMediaRule):
     39        * css/CSSReflectValue.h:
     40        * css/CSSStyleSheet.cpp:
     41        (WebCore::CSSStyleSheet::setDisabled):
     42        (WebCore::CSSStyleSheet::setMediaQueries):
     43        (WebCore::CSSStyleSheet::insertRule):
     44        (WebCore::CSSStyleSheet::deleteRule):
     45        (WebCore::CSSStyleSheet::isLoading):
     46        (WebCore::CSSStyleSheet::media):
     47        (WebCore::CSSStyleSheet::parentStyleSheet):
     48        (WebCore::CSSStyleSheet::ownerDocument):
     49        (WebCore::CSSStyleSheet::clearChildRuleCSSOMWrappers):
     50        (WebCore::CSSStyleSheet::RuleMutationScope::RuleMutationScope):
     51        * css/CSSStyleSheet.h:
     52        * css/PropertySetCSSStyleDeclaration.cpp:
     53        * css/StyleRule.cpp:
     54        (WebCore::StyleRuleBase::createCSSOMWrapper):
     55        (WebCore::StyleRuleBase::destroy):
     56        (WebCore::StyleRuleGroup::wrapperRemoveRule):
     57        (WebCore::StyleRuleMedia::StyleRuleMedia):
     58        * css/StyleRule.h:
     59        (WebCore::StyleRuleBase::deref):
     60        (WebCore::StyleRuleBase::StyleRuleBase):
     61        (WebCore::StyleRuleMedia::create):
     62        (WebCore::StyleRuleMedia::mediaQueries):
     63        (WebCore::StyleRuleMedia::copy):
     64        (isType):
     65        * css/StyleRuleImport.cpp:
     66        (WebCore::StyleRuleImport::create):
     67        (WebCore::StyleRuleImport::StyleRuleImport):
     68        * css/StyleRuleImport.h:
     69        * css/StyleSheetContents.cpp:
     70        (WebCore::StyleSheetContents::isCacheable):
     71        (WebCore::StyleSheetContents::parserAppendRule):
     72        (WebCore::StyleSheetContents::ruleAt):
     73        (WebCore::StyleSheetContents::parserSetEncodingFromCharsetRule):
     74        (WebCore::StyleSheetContents::wrapperInsertRule):
     75        * css/StyleSheetContents.h:
     76        (WebCore::StyleSheetContents::hasSyntacticallyValidCSSHeader):
     77        (WebCore::StyleSheetContents::parserSetUsesRemUnits):
     78        (WebCore::StyleSheetContents::parserSetUsesStyleBasedEditability):
     79        (WebCore::StyleSheetContents::copy):
     80        * dom/InlineStyleSheetOwner.cpp:
     81        (WebCore::InlineStyleSheetOwner::createSheet):
     82        * inspector/InspectorStyleSheet.cpp:
     83
    1842016-05-23  Zalan Bujtas  <zalan@apple.com>
    285
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r201305 r201318  
    27062706                    push(@implContent, "    auto& impl = castedThis->wrapped();\n") if !$attribute->isStatic;
    27072707                    if ($codeGenerator->IsSVGAnimatedType($type)) {
    2708                         push(@implContent, "    RefPtr<$type> obj = $jsType;\n");
     2708                        push(@implContent, "    auto obj = $jsType;\n");
    27092709                        push(@implContent, "    JSValue result = toJS(state, castedThis->globalObject(), obj.get());\n");
    27102710                    } else {
     
    29192919                        my $implGetterFunctionName = $codeGenerator->WK_lcfirst($attribute->signature->extendedAttributes->{"ImplementedAs"} || $name);
    29202920                        if ($attribute->signature->isNullable) {
    2921                             push(@implContent, "    RefPtr<${type}> forwardedImpl = castedThis->wrapped().${implGetterFunctionName}();\n");
     2921                            push(@implContent, "    auto forwardedImpl = castedThis->wrapped().${implGetterFunctionName}();\n");
    29222922                            push(@implContent, "    if (!forwardedImpl)\n");
    29232923                            push(@implContent, "        return false;\n");
     
    36603660                if ($function->isStatic) {
    36613661                    AddToImplIncludes("CallbackFunction.h");
    3662                     push(@$outputArray, "    RefPtr<$type> $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argumentIndex));\n");
     3662                    push(@$outputArray, "    auto $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argumentIndex));\n");
    36633663                } else {
    3664                     push(@$outputArray, "    RefPtr<$type> $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argumentIndex)), castedThis->globalObject());\n");
     3664                    push(@$outputArray, "    auto $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argumentIndex)), castedThis->globalObject());\n");
    36653665                }
    36663666            }
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp

    r201166 r201318  
    161161    if (UNLIKELY(!state->argument(0).isFunction()))
    162162        return throwArgumentMustBeFunctionError(*state, 0, "listener", "TestMediaQueryListListener", "method");
    163     RefPtr<MediaQueryListListener> listener = JSMediaQueryListListener::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
     163    auto listener = JSMediaQueryListListener::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    164164    impl.method(WTFMove(listener));
    165165    return JSValue::encode(jsUndefined());
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r201305 r201318  
    10161016    if (UNLIKELY(!state->argument(0).isObject()))
    10171017        return throwArgumentMustBeFunctionError(*state, 0, "testCallback", "TestObj", nullptr);
    1018     RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
     1018    auto testCallback = JSTestCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    10191019    if (UNLIKELY(!state->argument(1).isFunction()))
    10201020        return throwArgumentMustBeFunctionError(*state, 1, "testCallbackFunction", "TestObj", nullptr);
    1021     RefPtr<TestCallbackFunction> testCallbackFunction = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
     1021    auto testCallbackFunction = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
    10221022    auto object = TestObj::create(*testCallback, *testCallbackFunction);
    10231023    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
     
    38533853        return throwSetterTypeError(*state, "TestObj", "putForwardsNullableAttribute");
    38543854    }
    3855     RefPtr<TestNode> forwardedImpl = castedThis->wrapped().putForwardsNullableAttribute();
     3855    auto forwardedImpl = castedThis->wrapped().putForwardsNullableAttribute();
    38563856    if (!forwardedImpl)
    38573857        return false;
     
    50225022    if (UNLIKELY(!state->argument(0).isObject()))
    50235023        return throwArgumentMustBeFunctionError(*state, 0, "callback", "TestObj", "methodWithCallbackArg");
    5024     RefPtr<TestCallback> callback = JSTestCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
     5024    auto callback = JSTestCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    50255025    impl.methodWithCallbackArg(WTFMove(callback));
    50265026    return JSValue::encode(jsUndefined());
     
    50425042    if (UNLIKELY(!state->argument(1).isObject()))
    50435043        return throwArgumentMustBeFunctionError(*state, 1, "callback", "TestObj", "methodWithNonCallbackArgAndCallbackArg");
    5044     RefPtr<TestCallback> callback = JSTestCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
     5044    auto callback = JSTestCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
    50455045    impl.methodWithNonCallbackArgAndCallbackArg(WTFMove(nonCallback), WTFMove(callback));
    50465046    return JSValue::encode(jsUndefined());
     
    50775077    if (UNLIKELY(!state->argument(0).isFunction()))
    50785078        return throwArgumentMustBeFunctionError(*state, 0, "callback", "TestObj", "methodWithCallbackFunctionArg");
    5079     RefPtr<TestCallbackFunction> callback = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
     5079    auto callback = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    50805080    impl.methodWithCallbackFunctionArg(WTFMove(callback));
    50815081    return JSValue::encode(jsUndefined());
     
    50975097    if (UNLIKELY(!state->argument(1).isFunction()))
    50985098        return throwArgumentMustBeFunctionError(*state, 1, "callback", "TestObj", "methodWithNonCallbackArgAndCallbackFunctionArg");
    5099     RefPtr<TestCallbackFunction> callback = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
     5099    auto callback = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
    51005100    impl.methodWithNonCallbackArgAndCallbackFunctionArg(WTFMove(nonCallback), WTFMove(callback));
    51015101    return JSValue::encode(jsUndefined());
     
    51385138    if (UNLIKELY(!state->argument(0).isObject()))
    51395139        return throwArgumentMustBeFunctionError(*state, 0, "callback", "TestObj", "staticMethodWithCallbackArg");
    5140     RefPtr<TestCallback> callback = createFunctionOnlyCallback<JSTestCallback>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument(0));
     5140    auto callback = createFunctionOnlyCallback<JSTestCallback>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument(0));
    51415141    TestObj::staticMethodWithCallbackArg(WTFMove(callback));
    51425142    return JSValue::encode(jsUndefined());
     
    52705270    if (UNLIKELY(!state->argument(0).isObject()))
    52715271        return throwArgumentMustBeFunctionError(*state, 0, "callback", "TestObj", "overloadedMethod");
    5272     RefPtr<TestCallback> callback = JSTestCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
     5272    auto callback = JSTestCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    52735273    impl.overloadedMethod(WTFMove(callback));
    52745274    return JSValue::encode(jsUndefined());
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp

    r201166 r201318  
    135135    if (UNLIKELY(!state->argument(1).isObject()))
    136136        return throwArgumentMustBeFunctionError(*state, 1, "testCallback", "TestTypedefs", nullptr);
    137     RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
     137    auto testCallback = JSTestCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
    138138    auto object = TestTypedefs::create(hello, *testCallback);
    139139    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
  • trunk/Source/WebCore/css/CSSBasicShapes.cpp

    r201290 r201318  
    5252}
    5353
    54 static Ref<CSSPrimitiveValue> buildSerializablePositionOffset(PassRefPtr<CSSPrimitiveValue> offset, CSSValueID defaultSide)
     54static Ref<CSSPrimitiveValue> buildSerializablePositionOffset(CSSPrimitiveValue* offset, CSSValueID defaultSide)
    5555{
    5656    CSSValueID side = defaultSide;
     
    111111String CSSBasicShapeCircle::cssText() const
    112112{
    113     Ref<CSSPrimitiveValue> normalizedCX = buildSerializablePositionOffset(m_centerX, CSSValueLeft);
    114     Ref<CSSPrimitiveValue> normalizedCY = buildSerializablePositionOffset(m_centerY, CSSValueTop);
     113    Ref<CSSPrimitiveValue> normalizedCX = buildSerializablePositionOffset(m_centerX.get(), CSSValueLeft);
     114    Ref<CSSPrimitiveValue> normalizedCY = buildSerializablePositionOffset(m_centerY.get(), CSSValueTop);
    115115
    116116    String radius;
     
    168168String CSSBasicShapeEllipse::cssText() const
    169169{
    170     Ref<CSSPrimitiveValue> normalizedCX = buildSerializablePositionOffset(m_centerX, CSSValueLeft);
    171     Ref<CSSPrimitiveValue> normalizedCY = buildSerializablePositionOffset(m_centerY, CSSValueTop);
     170    Ref<CSSPrimitiveValue> normalizedCX = buildSerializablePositionOffset(m_centerX.get(), CSSValueLeft);
     171    Ref<CSSPrimitiveValue> normalizedCY = buildSerializablePositionOffset(m_centerY.get(), CSSValueTop);
    172172
    173173    String radiusX;
  • trunk/Source/WebCore/css/CSSCalculationValue.cpp

    r200977 r201318  
    201201    WTF_MAKE_FAST_ALLOCATED;
    202202public:
    203     static Ref<CSSCalcPrimitiveValue> create(PassRefPtr<CSSPrimitiveValue> value, bool isInteger)
    204     {
    205         return adoptRef(*new CSSCalcPrimitiveValue(value, isInteger));
     203    static Ref<CSSCalcPrimitiveValue> create(Ref<CSSPrimitiveValue>&& value, bool isInteger)
     204    {
     205        return adoptRef(*new CSSCalcPrimitiveValue(WTFMove(value), isInteger));
    206206    }
    207207
     
    233233        case CalcPercent:
    234234        case CalcPercentLength: {
    235             CSSPrimitiveValue* primitiveValue = m_value.get();
    236             return std::make_unique<CalcExpressionLength>(primitiveValue
    237                 ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion>(conversionData) : Length(Undefined));
     235            return std::make_unique<CalcExpressionLength>(m_value->convertToLength<FixedFloatConversion | PercentConversion>(conversionData));
    238236        }
    239237        // Only types that could be part of a Length expression can be converted
     
    284282            return false;
    285283
    286         return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveValue&>(other).m_value);
     284        return compareCSSValue(m_value, static_cast<const CSSCalcPrimitiveValue&>(other).m_value);
    287285    }
    288286
     
    294292
    295293private:
    296     explicit CSSCalcPrimitiveValue(PassRefPtr<CSSPrimitiveValue> value, bool isInteger)
     294    explicit CSSCalcPrimitiveValue(Ref<CSSPrimitiveValue>&& value, bool isInteger)
    297295        : CSSCalcExpressionNode(unitCategory((CSSPrimitiveValue::UnitTypes)value->primitiveType()), isInteger)
    298         , m_value(value)
    299     {
    300     }
    301 
    302     RefPtr<CSSPrimitiveValue> m_value;
     296        , m_value(WTFMove(value))
     297    {
     298    }
     299
     300    Ref<CSSPrimitiveValue> m_value;
    303301};
    304302
     
    611609            return false;
    612610
    613         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
    614         result->value = CSSCalcPrimitiveValue::create(&primitiveValue, parserValue->isInt);
     611        result->value = CSSCalcPrimitiveValue::create(Ref<CSSPrimitiveValue>(downcast<CSSPrimitiveValue>(*value)), parserValue->isInt);
    615612
    616613        ++*index;
  • trunk/Source/WebCore/css/CSSMediaRule.cpp

    r175548 r201318  
    2828#include "CSSStyleSheet.h"
    2929#include "ExceptionCode.h"
     30#include "MediaList.h"
    3031#include "StyleRule.h"
    3132#include <wtf/text/StringBuilder.h>
     
    6667{
    6768    if (!mediaQueries())
    68         return 0;
     69        return nullptr;
    6970    if (!m_mediaCSSOMWrapper)
    7071        m_mediaCSSOMWrapper = MediaList::create(mediaQueries(), const_cast<CSSMediaRule*>(this));
  • trunk/Source/WebCore/css/CSSMediaRule.h

    r197563 r201318  
    2121 */
    2222
    23 #ifndef CSSMediaRule_h
    24 #define CSSMediaRule_h
     23#pragma once
    2524
    2625#include "CSSGroupingRule.h"
    27 #include "MediaList.h"
    2826
    2927namespace WebCore {
    3028
     29class MediaList;
    3130class StyleRuleMedia;
    3231
     
    5554
    5655SPECIALIZE_TYPE_TRAITS_CSS_RULE(CSSMediaRule, CSSRule::MEDIA_RULE)
    57 
    58 #endif // CSSMediaRule_h
  • trunk/Source/WebCore/css/CSSOMUtils.h

    r166044 r201318  
    2929 */
    3030
    31 #ifndef CSSOMUtils_h
    32 #define CSSOMUtils_h
     31#pragma once
    3332
    34 #include <unicode/utypes.h>
     33#include <unicode/umachine.h>
    3534#include <wtf/Forward.h>
    36 #include <wtf/Vector.h>
    3735
    3836// Utilities for CSSOM http://dev.w3.org/csswg/cssom/
     
    4745
    4846} // namespace WebCore
    49 
    50 #endif // CSSOMUtils_h
  • trunk/Source/WebCore/css/CSSParser.cpp

    r201290 r201318  
    1280612806        return nullptr;
    1280712807    }
    12808     auto rule = StyleRuleImport::create(url, media);
     12808    auto rule = StyleRuleImport::create(url, media.releaseNonNull());
    1280912809    processAndAddNewRuleToSourceTreeIfNeeded();
    1281012810    return WTFMove(rule);
     
    1282112821        rule = StyleRuleMedia::create(MediaQuerySet::create(), emptyRules);
    1282212822    } else
    12823         rule = StyleRuleMedia::create(media, rules ? *rules : emptyRules);
     12823        rule = StyleRuleMedia::create(media.releaseNonNull(), rules ? *rules : emptyRules);
    1282412824    processAndAddNewRuleToSourceTreeIfNeeded();
    1282512825    return rule.releaseNonNull();
  • trunk/Source/WebCore/css/CSSReflectValue.h

    r201290 r201318  
    2424 */
    2525
    26 #ifndef CSSReflectValue_h
    27 #define CSSReflectValue_h
     26#pragma once
    2827
    2928#include "CSSReflectionDirection.h"
    3029#include "CSSValue.h"
    31 #include <wtf/PassRefPtr.h>
    3230#include <wtf/RefPtr.h>
    3331
     
    7270
    7371SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSReflectValue, isReflectValue())
    74 
    75 #endif // CSSReflectValue_h
  • trunk/Source/WebCore/css/CSSStyleSheet.cpp

    r201290 r201318  
    223223}
    224224
    225 void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries)
    226 {
    227     m_mediaQueries = mediaQueries;
     225void CSSStyleSheet::setMediaQueries(Ref<MediaQuerySet>&& mediaQueries)
     226{
     227    m_mediaQueries = WTFMove(mediaQueries);
    228228    if (m_mediaCSSOMWrapper && m_mediaQueries)
    229229        m_mediaCSSOMWrapper->reattach(m_mediaQueries.get());
     
    311311    RuleMutationScope mutationScope(this, RuleInsertion, is<StyleRuleKeyframes>(*rule) ? downcast<StyleRuleKeyframes>(rule.get()) : nullptr);
    312312
    313     bool success = m_contents.get().wrapperInsertRule(rule, index);
     313    bool success = m_contents.get().wrapperInsertRule(rule.releaseNonNull(), index);
    314314    if (!success) {
    315315        ec = HIERARCHY_REQUEST_ERR;
     
    337337    if (!m_childRuleCSSOMWrappers.isEmpty()) {
    338338        if (m_childRuleCSSOMWrappers[index])
    339             m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0);
     339            m_childRuleCSSOMWrappers[index]->setParentStyleSheet(nullptr);
    340340        m_childRuleCSSOMWrappers.remove(index);
    341341    }
     
    382382
    383383MediaList* CSSStyleSheet::media() const
    384 { 
     384{
    385385    if (!m_mediaQueries)
    386         return 0;
     386        return nullptr;
    387387
    388388    if (!m_mediaCSSOMWrapper)
     
    393393CSSStyleSheet* CSSStyleSheet::parentStyleSheet() const
    394394{
    395     return m_ownerRule ? m_ownerRule->parentStyleSheet() : 0;
     395    return m_ownerRule ? m_ownerRule->parentStyleSheet() : nullptr;
    396396}
    397397
     
    401401    while (root->parentStyleSheet())
    402402        root = root->parentStyleSheet();
    403     return root->ownerNode() ? &root->ownerNode()->document() : 0;
     403    return root->ownerNode() ? &root->ownerNode()->document() : nullptr;
    404404}
    405405
     
    419419
    420420CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule)
    421     : m_styleSheet(rule ? rule->parentStyleSheet() : 0)
     421    : m_styleSheet(rule ? rule->parentStyleSheet() : nullptr)
    422422    , m_mutationType(OtherMutation)
    423423    , m_contentsWereClonedForMutation(ContentsWereNotClonedForMutation)
  • trunk/Source/WebCore/css/CSSStyleSheet.h

    r200110 r201318  
    2323
    2424#include "CSSParserMode.h"
    25 #include "CSSRule.h"
    2625#include "StyleSheet.h"
    2726#include <memory>
     
    8685    Document* ownerDocument() const;
    8786    MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
    88     void setMediaQueries(PassRefPtr<MediaQuerySet>);
     87    void setMediaQueries(Ref<MediaQuerySet>&&);
    8988    void setTitle(const String& title) { m_title = title; }
    9089
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r200769 r201318  
    2525#include "CSSCustomPropertyValue.h"
    2626#include "CSSParser.h"
     27#include "CSSRule.h"
    2728#include "CSSStyleSheet.h"
    2829#include "HTMLNames.h"
  • trunk/Source/WebCore/css/StyleRule.cpp

    r200626 r201318  
    3333#include "CSSSupportsRule.h"
    3434#include "CSSUnknownRule.h"
     35#include "MediaList.h"
    3536#include "StyleProperties.h"
    3637#include "StyleRuleImport.h"
     
    4647COMPILE_ASSERT(sizeof(StyleRuleBase) == sizeof(SameSizeAsStyleRuleBase), StyleRuleBase_should_stay_small);
    4748
    48 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const
    49 {
    50     return createCSSOMWrapper(parentSheet, 0);
    51 }
    52 
    53 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const
     49RefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const
     50{
     51    return createCSSOMWrapper(parentSheet, nullptr);
     52}
     53
     54RefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const
    5455{
    55     return createCSSOMWrapper(0, parentRule);
     56    return createCSSOMWrapper(nullptr, parentRule);
    5657}
    5758
     
    330331
    331332
    332 StyleRuleMedia::StyleRuleMedia(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
     333StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    333334    : StyleRuleGroup(Media, adoptRules)
    334     , m_mediaQueries(media)
     335    , m_mediaQueries(WTFMove(media))
    335336{
    336337}
  • trunk/Source/WebCore/css/StyleRule.h

    r200626 r201318  
    2020 */
    2121
    22 #ifndef StyleRule_h
    23 #define StyleRule_h
     22#pragma once
    2423
    2524#include "CSSSelectorList.h"
    26 #include "MediaList.h"
    2725#include "StyleProperties.h"
    2826#include <wtf/RefPtr.h>
     
    3432class CSSStyleRule;
    3533class CSSStyleSheet;
     34class MediaQuerySet;
    3635class MutableStyleProperties;
    3736class StyleProperties;
     
    8382
    8483    // FIXME: There shouldn't be any need for the null parent version.
    85     PassRefPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet = 0) const;
    86     PassRefPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) const;
     84    RefPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet = nullptr) const;
     85    RefPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) const;
    8786
    8887protected:
     
    194193class StyleRuleMedia : public StyleRuleGroup {
    195194public:
    196     static Ref<StyleRuleMedia> create(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    197     {
    198         return adoptRef(*new StyleRuleMedia(media, adoptRules));
     195    static Ref<StyleRuleMedia> create(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
     196    {
     197        return adoptRef(*new StyleRuleMedia(WTFMove(media), adoptRules));
    199198    }
    200199
     
    204203
    205204private:
    206     StyleRuleMedia(PassRefPtr<MediaQuerySet>, Vector<RefPtr<StyleRuleBase>>& adoptRules);
     205    StyleRuleMedia(Ref<MediaQuerySet>&&, Vector<RefPtr<StyleRuleBase>>& adoptRules);
    207206    StyleRuleMedia(const StyleRuleMedia&);
    208207
     
    298297SPECIALIZE_TYPE_TRAITS_END()
    299298#endif // ENABLE(CSS_DEVICE_ADAPTATION)
    300 
    301 #endif // StyleRule_h
  • trunk/Source/WebCore/css/StyleRuleImport.cpp

    r187489 r201318  
    2929#include "CachedResourceRequestInitiators.h"
    3030#include "Document.h"
     31#include "MediaList.h"
    3132#include "SecurityOrigin.h"
    3233#include "StyleSheetContents.h"
     
    3536namespace WebCore {
    3637
    37 Ref<StyleRuleImport> StyleRuleImport::create(const String& href, PassRefPtr<MediaQuerySet> media)
     38Ref<StyleRuleImport> StyleRuleImport::create(const String& href, Ref<MediaQuerySet>&& media)
    3839{
    39     return adoptRef(*new StyleRuleImport(href, media));
     40    return adoptRef(*new StyleRuleImport(href, WTFMove(media)));
    4041}
    4142
    42 StyleRuleImport::StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet> media)
     43StyleRuleImport::StyleRuleImport(const String& href, Ref<MediaQuerySet>&& media)
    4344    : StyleRuleBase(Import, 0)
    4445    , m_parentStyleSheet(0)
    4546    , m_styleSheetClient(this)
    4647    , m_strHref(href)
    47     , m_mediaQueries(media)
     48    , m_mediaQueries(WTFMove(media))
    4849    , m_cachedSheet(0)
    4950    , m_loading(false)
  • trunk/Source/WebCore/css/StyleRuleImport.h

    r177259 r201318  
    3737    WTF_MAKE_FAST_ALLOCATED;
    3838public:
    39     static Ref<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>);
     39    static Ref<StyleRuleImport> create(const String& href, Ref<MediaQuerySet>&&);
    4040
    4141    ~StyleRuleImport();
     
    7171    friend class ImportedStyleSheetClient;
    7272
    73     StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet>);
     73    StyleRuleImport(const String& href, Ref<MediaQuerySet>&&);
    7474
    7575    StyleSheetContents* m_parentStyleSheet;
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r200895 r201318  
    130130}
    131131
    132 void StyleSheetContents::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
     132void StyleSheetContents::parserAppendRule(Ref<StyleRuleBase>&& rule)
    133133{
    134134    ASSERT(!rule->isCharsetRule());
    135     if (is<StyleRuleImport>(*rule)) {
     135    if (is<StyleRuleImport>(rule)) {
    136136        // Parser enforces that @import rules come before anything else except @charset.
    137137        ASSERT(m_childRules.isEmpty());
    138         m_importRules.append(downcast<StyleRuleImport>(rule.get()));
     138        m_importRules.append(downcast<StyleRuleImport>(rule.ptr()));
    139139        m_importRules.last()->setParentStyleSheet(this);
    140140        m_importRules.last()->requestStyleSheet();
     
    144144#if ENABLE(RESOLUTION_MEDIA_QUERY)
    145145    // Add warning message to inspector if dpi/dpcm values are used for screen media.
    146     if (is<StyleRuleMedia>(*rule))
    147         reportMediaQueryWarningIfNeeded(singleOwnerDocument(), downcast<StyleRuleMedia>(*rule).mediaQueries());
     146    if (is<StyleRuleMedia>(rule))
     147        reportMediaQueryWarningIfNeeded(singleOwnerDocument(), downcast<StyleRuleMedia>(rule.get()).mediaQueries());
    148148#endif
    149149
    150150    // NOTE: The selector list has to fit into RuleData. <http://webkit.org/b/118369>
    151151    // If we're adding a rule with a huge number of selectors, split it up into multiple rules
    152     if (is<StyleRule>(*rule) && downcast<StyleRule>(*rule).selectorList().componentCount() > RuleData::maximumSelectorComponentCount) {
    153         Vector<RefPtr<StyleRule>> rules = downcast<StyleRule>(*rule).splitIntoMultipleRulesWithMaximumSelectorComponentCount(RuleData::maximumSelectorComponentCount);
     152    if (is<StyleRule>(rule) && downcast<StyleRule>(rule.get()).selectorList().componentCount() > RuleData::maximumSelectorComponentCount) {
     153        Vector<RefPtr<StyleRule>> rules = downcast<StyleRule>(rule.get()).splitIntoMultipleRulesWithMaximumSelectorComponentCount(RuleData::maximumSelectorComponentCount);
    154154        m_childRules.appendVector(rules);
    155155        return;
    156156    }
    157157
    158     m_childRules.append(rule);
     158    m_childRules.append(WTFMove(rule));
    159159}
    160160
     
    208208}
    209209
    210 bool StyleSheetContents::wrapperInsertRule(PassRefPtr<StyleRuleBase> rule, unsigned index)
     210bool StyleSheetContents::wrapperInsertRule(Ref<StyleRuleBase>&& rule, unsigned index)
    211211{
    212212    ASSERT(m_isMutable);
     
    227227    if (childVectorIndex < m_importRules.size() || (childVectorIndex == m_importRules.size() && rule->isImportRule())) {
    228228        // Inserting non-import rule before @import is not allowed.
    229         if (!is<StyleRuleImport>(*rule))
     229        if (!is<StyleRuleImport>(rule))
    230230            return false;
    231         m_importRules.insert(childVectorIndex, downcast<StyleRuleImport>(rule.get()));
     231        m_importRules.insert(childVectorIndex, downcast<StyleRuleImport>(rule.ptr()));
    232232        m_importRules[childVectorIndex]->setParentStyleSheet(this);
    233233        m_importRules[childVectorIndex]->requestStyleSheet();
     
    236236    }
    237237    // Inserting @import rule after a non-import rule is not allowed.
    238     if (is<StyleRuleImport>(*rule))
     238    if (is<StyleRuleImport>(rule))
    239239        return false;
    240240    childVectorIndex -= m_importRules.size();
    241241
    242242    // If the number of selectors would overflow RuleData, we drop the operation.
    243     if (is<StyleRule>(*rule) && downcast<StyleRule>(*rule).selectorList().componentCount() > RuleData::maximumSelectorComponentCount)
    244         return false;
    245 
    246     m_childRules.insert(childVectorIndex, rule);
     243    if (is<StyleRule>(rule) && downcast<StyleRule>(rule.get()).selectorList().componentCount() > RuleData::maximumSelectorComponentCount)
     244        return false;
     245
     246    m_childRules.insert(childVectorIndex, WTFMove(rule));
    247247    return true;
    248248}
  • trunk/Source/WebCore/css/StyleSheetContents.h

    r195304 r201318  
    9595
    9696    void parserAddNamespace(const AtomicString& prefix, const AtomicString& uri);
    97     void parserAppendRule(PassRefPtr<StyleRuleBase>);
     97    void parserAppendRule(Ref<StyleRuleBase>&&);
    9898    void parserSetEncodingFromCharsetRule(const String& encoding);
    9999    void parserSetUsesRemUnits() { m_usesRemUnits = true; }
     
    128128    unsigned estimatedSizeInBytes() const;
    129129   
    130     bool wrapperInsertRule(PassRefPtr<StyleRuleBase>, unsigned index);
     130    bool wrapperInsertRule(Ref<StyleRuleBase>&&, unsigned index);
    131131    void wrapperDeleteRule(unsigned index);
    132132
  • trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp

    r197944 r201318  
    159159
    160160    m_sheet = CSSStyleSheet::createInline(element, URL(), m_startTextPosition, document.encoding());
    161     m_sheet->setMediaQueries(mediaQueries.release());
     161    m_sheet->setMediaQueries(mediaQueries.releaseNonNull());
    162162    m_sheet->setTitle(element.title());
    163163    m_sheet->contents().parseStringAtPosition(text, m_startTextPosition, m_isParsingChildren);
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r201290 r201318  
    4646#include "InspectorCSSAgent.h"
    4747#include "InspectorPageAgent.h"
     48#include "MediaList.h"
    4849#include "Node.h"
    4950#include "SVGElement.h"
Note: See TracChangeset for help on using the changeset viewer.