Changeset 175648 in webkit


Ignore:
Timestamp:
Nov 5, 2014 4:16:27 PM (9 years ago)
Author:
Chris Dumez
Message:

Allow constructing a PassRef from a Ref
https://bugs.webkit.org/show_bug.cgi?id=138389

Reviewed by Andreas Kling.

Source/WebCore:

Remove calls to Ref::get() now that a PassRef can be directly
constructed from a Ref.

No new tests, no behavior change.

  • css/CSSValuePool.cpp:

(WebCore::CSSValuePool::createColorValue):

  • css/CSSValuePool.h:

(WebCore::CSSValuePool::createInheritedValue):
(WebCore::CSSValuePool::createImplicitInitialValue):
(WebCore::CSSValuePool::createExplicitInitialValue):

  • html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::setCSSStyleSheet):

Source/WTF:

Allow constructing a PassRef from a Ref, similarly to PassRefPtr that
can be constructed from a RefPtr already. This avoids having to call
Ref::get() and simplifies the code a bit.

  • wtf/PassRef.h:

(WTF::PassRef<T>::PassRef):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r175647 r175648  
     12014-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Allow constructing a PassRef from a Ref
     4        https://bugs.webkit.org/show_bug.cgi?id=138389
     5
     6        Reviewed by Andreas Kling.
     7
     8        Allow constructing a PassRef from a Ref, similarly to PassRefPtr that
     9        can be constructed from a RefPtr already. This avoids having to call
     10        Ref::get() and simplifies the code a bit.
     11
     12        * wtf/PassRef.h:
     13        (WTF::PassRef<T>::PassRef):
     14
    1152014-11-05  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/Source/WTF/wtf/PassRef.h

    r175583 r175648  
    4141    PassRef(T&);
    4242    PassRef(PassRef&&);
     43    template<typename U> PassRef(const Ref<U>&);
    4344    template<typename U> PassRef(PassRef<U>);
    4445
     
    9798#endif
    9899{
     100}
     101
     102template<typename T> template<typename U> inline PassRef<T>::PassRef(const Ref<U>& other)
     103    : m_reference(const_cast<T&>(other.get()))
     104#ifndef NDEBUG
     105    , m_gaveUpReference(false)
     106#endif
     107{
     108    m_reference.ref();
    99109}
    100110
  • trunk/Source/WebCore/ChangeLog

    r175647 r175648  
     12014-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Allow constructing a PassRef from a Ref
     4        https://bugs.webkit.org/show_bug.cgi?id=138389
     5
     6        Reviewed by Andreas Kling.
     7
     8        Remove calls to Ref::get() now that a PassRef can be directly
     9        constructed from a Ref.
     10
     11        No new tests, no behavior change.
     12
     13        * css/CSSValuePool.cpp:
     14        (WebCore::CSSValuePool::createColorValue):
     15        * css/CSSValuePool.h:
     16        (WebCore::CSSValuePool::createInheritedValue):
     17        (WebCore::CSSValuePool::createImplicitInitialValue):
     18        (WebCore::CSSValuePool::createExplicitInitialValue):
     19        * html/HTMLLinkElement.cpp:
     20        (WebCore::HTMLLinkElement::setCSSStyleSheet):
     21
    1222014-11-05  Dan Bernstein  <mitz@apple.com>
    223
  • trunk/Source/WebCore/css/CSSValuePool.cpp

    r166486 r175648  
    7070    // These are the empty and deleted values of the hash table.
    7171    if (rgbValue == Color::transparent)
    72         return m_colorTransparent.get();
     72        return m_colorTransparent;
    7373    if (rgbValue == Color::white)
    74         return m_colorWhite.get();
     74        return m_colorWhite;
    7575    // Just because it is common.
    7676    if (rgbValue == Color::black)
    77         return m_colorBlack.get();
     77        return m_colorBlack;
    7878
    7979    // Remove one entry at random if the cache grows too large.
  • trunk/Source/WebCore/css/CSSValuePool.h

    r167936 r175648  
    4646    PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&);
    4747    PassRef<CSSPrimitiveValue> createFontFamilyValue(const String&);
    48     PassRef<CSSInheritedValue> createInheritedValue() { return m_inheritedValue.get(); }
    49     PassRef<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue.get(); }
    50     PassRef<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue.get(); }
     48    PassRef<CSSInheritedValue> createInheritedValue() { return m_inheritedValue; }
     49    PassRef<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue; }
     50    PassRef<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue; }
    5151    PassRef<CSSPrimitiveValue> createIdentifierValue(CSSValueID identifier);
    5252    PassRef<CSSPrimitiveValue> createIdentifierValue(CSSPropertyID identifier);
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r175583 r175648  
    329329
    330330    Ref<StyleSheetContents> styleSheet(StyleSheetContents::create(href, parserContext));
    331     m_sheet = CSSStyleSheet::create(styleSheet.get(), this);
     331    m_sheet = CSSStyleSheet::create(styleSheet, this);
    332332    m_sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(m_media));
    333333    m_sheet->setTitle(title());
     
    340340
    341341    if (styleSheet.get().isCacheable())
    342         const_cast<CachedCSSStyleSheet*>(cachedStyleSheet)->saveParsedStyleSheet(styleSheet.get());
     342        const_cast<CachedCSSStyleSheet*>(cachedStyleSheet)->saveParsedStyleSheet(styleSheet);
    343343}
    344344
Note: See TracChangeset for help on using the changeset viewer.