Allow implicit conversion from Ref<T> to T&
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Nov 2014 07:22:18 +0000 (07:22 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Nov 2014 07:22:18 +0000 (07:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138331

Reviewed by Andreas Kling.

Source/WebCore:

Remove unnecessary calls to Ref<T>::get() now that a Ref<T> can be
converted implicitly to a T&.

No new tests, no behavior change.

Source/WebKit2:

Remove unnecessary calls to Ref<T>::get() now that a Ref<T> can be
converted implicitly to a T&.

Source/WTF:

Allow implicit conversion from Ref<T> to T& to reduce the amount of
Ref<>::get() calls in the code and increase readability. Unlike for
RefPtr, doing this for Ref should not be error prone.

* wtf/Ref.h:
(WTF::Ref::operator T&):
(WTF::Ref::operator const T&):
* wtf/RunLoop.cpp:
(WTF::RunLoop::Holder::runLoop):

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

43 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Ref.h
Source/WTF/wtf/RunLoop.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMWindowShell.h
Source/WebCore/css/CSSStyleSheet.h
Source/WebCore/css/CSSToStyleMap.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueList.cpp
Source/WebCore/css/DeprecatedStyleBuilder.cpp
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleRule.h
Source/WebCore/css/WebKitCSSKeyframeRule.h
Source/WebCore/dom/ChildListMutationScope.cpp
Source/WebCore/dom/ChildNodeList.cpp
Source/WebCore/dom/ChildNodeList.h
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/EditCommand.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/editing/markup.cpp
Source/WebCore/html/canvas/CanvasGradient.h
Source/WebCore/html/canvas/CanvasPattern.h
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/animation/AnimationController.cpp
Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp
Source/WebCore/platform/graphics/ca/TileCoverageMap.h
Source/WebCore/platform/graphics/ca/TileGrid.h
Source/WebCore/rendering/ClipPathOperation.h
Source/WebCore/rendering/RenderNamedFlowThread.h
Source/WebCore/rendering/style/StyleGeneratedImage.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.h
Source/WebKit2/WebProcess/UserContent/WebUserContentController.h

index f96180c..71c72b3 100644 (file)
@@ -1,3 +1,20 @@
+2014-11-03  Chris Dumez  <cdumez@apple.com>
+
+        Allow implicit conversion from Ref<T> to T&
+        https://bugs.webkit.org/show_bug.cgi?id=138331
+
+        Reviewed by Andreas Kling.
+
+        Allow implicit conversion from Ref<T> to T& to reduce the amount of
+        Ref<>::get() calls in the code and increase readability. Unlike for
+        RefPtr, doing this for Ref should not be error prone.
+
+        * wtf/Ref.h:
+        (WTF::Ref::operator T&):
+        (WTF::Ref::operator const T&):
+        * wtf/RunLoop.cpp:
+        (WTF::RunLoop::Holder::runLoop):
+
 2014-10-31  Jeffrey Pfau  <jpfau@apple.com>
 
         Unreviewed, fix ASan build after r175382
index f9c6588..e3f34dc 100644 (file)
@@ -61,6 +61,9 @@ public:
     const T& get() const { return *m_ptr; }
     T& get() { return *m_ptr; }
 
+    operator T&() { return *m_ptr; }
+    operator const T&() const { return *m_ptr; }
+
     template<typename U> PassRef<T> replace(PassRef<U>) WARN_UNUSED_RETURN;
 
 private:
index 85ad6d8..4d4310a 100644 (file)
@@ -41,7 +41,7 @@ public:
     {
     }
 
-    RunLoop& runLoop() { return m_runLoop.get(); }
+    RunLoop& runLoop() { return m_runLoop; }
 
 private:
     Ref<RunLoop> m_runLoop;
index 5482dc4..96d1a48 100644 (file)
@@ -1,3 +1,15 @@
+2014-11-03  Chris Dumez  <cdumez@apple.com>
+
+        Allow implicit conversion from Ref<T> to T&
+        https://bugs.webkit.org/show_bug.cgi?id=138331
+
+        Reviewed by Andreas Kling.
+
+        Remove unnecessary calls to Ref<T>::get() now that a Ref<T> can be
+        converted implicitly to a T&.
+
+        No new tests, no behavior change.
+
 2014-11-03  Simon Fraser  <simon.fraser@apple.com>
 
         Non-fast scrollable region overlay offsets the overlay by topContentInset
index 531053d..cedb59c 100644 (file)
@@ -62,7 +62,7 @@ namespace WebCore {
             return JSC::Structure::create(vm, 0, prototype, JSC::TypeInfo(JSC::PureForwardingProxyType, StructureFlags), info());
         }
 
-        DOMWrapperWorld& world() { return m_world.get(); }
+        DOMWrapperWorld& world() { return m_world; }
 
     protected:
         JSDOMWindowShell(JSC::VM&, JSC::Structure*, DOMWrapperWorld&);
index 20593a1..4017b9f 100644 (file)
@@ -113,7 +113,7 @@ public:
     void clearChildRuleCSSOMWrappers();
     void reattachChildRuleCSSOMWrappers();
 
-    StyleSheetContents& contents() { return m_contents.get(); }
+    StyleSheetContents& contents() { return m_contents; }
 
     void detachFromDocument() { m_ownerNode = nullptr; }
 
index 44a5762..016f332 100644 (file)
@@ -550,7 +550,7 @@ void CSSToStyleMap::mapNinePieceImage(CSSPropertyID property, CSSValue* value, N
             )
             image.setImage(styleImage(imageProperty, current.get()));
         else if (is<CSSBorderImageSliceValue>(current.get()))
-            mapNinePieceImageSlice(current.get(), image);
+            mapNinePieceImageSlice(current, image);
         else if (is<CSSValueList>(current.get())) {
             CSSValueList& slashList = downcast<CSSValueList>(current.get());
             // Map in the image slices.
@@ -566,7 +566,7 @@ void CSSToStyleMap::mapNinePieceImage(CSSPropertyID property, CSSValue* value, N
                 image.setOutset(mapNinePieceImageQuad(*slashList.item(2)));
         } else if (is<CSSPrimitiveValue>(current.get())) {
             // Set the appropriate rules for stretch/round/repeat of the slices.
-            mapNinePieceImageRepeat(current.get(), image);
+            mapNinePieceImageRepeat(current, image);
         }
     }
 
index 0e816c2..01ee62a 100644 (file)
@@ -247,7 +247,7 @@ inline bool compareCSSValuePtr(const RefPtr<CSSValueType>& first, const RefPtr<C
 template<typename CSSValueType>
 inline bool compareCSSValue(const Ref<CSSValueType>& first, const Ref<CSSValueType>& second)
 {
-    return first.get().equals(second.get());
+    return first.get().equals(second);
 }
 
 } // namespace WebCore
index 9eaa7aa..911844e 100644 (file)
@@ -96,8 +96,8 @@ PassRefPtr<CSSValueList> CSSValueList::copy()
     default:
         ASSERT_NOT_REACHED();
     }
-    for (unsigned i = 0, size = m_values.size(); i < size; ++i)
-        newList->append(m_values[i].get());
+    for (auto& value : m_values)
+        newList->append(value.get());
     return newList.release();
 }
 
@@ -119,10 +119,10 @@ String CSSValueList::customCSSText() const
         ASSERT_NOT_REACHED();
     }
 
-    for (unsigned i = 0, size = m_values.size(); i < size; i++) {
+    for (auto& value : m_values) {
         if (!result.isEmpty())
             result.append(separator);
-        result.append(m_values[i].get().cssText());
+        result.append(value.get().cssText());
     }
 
     return result.toString();
@@ -137,7 +137,7 @@ bool CSSValueList::equals(const CSSValueList& other) const
         return false;
 
     for (unsigned i = 0, size = m_values.size(); i < size; ++i) {
-        if (!m_values[i].get().equals(other.m_values[i].get()))
+        if (!m_values[i].get().equals(other.m_values[i]))
             return false;
     }
     return true;
index c2b4875..e727ed2 100644 (file)
@@ -1579,7 +1579,7 @@ public:
             for (auto& currentValue : downcast<CSSValueList>(*value)) {
                 if (childIndex <= list->size())
                     list->append(Animation::create());
-                map(styleResolver, list->animation(childIndex), currentValue.get());
+                map(styleResolver, list->animation(childIndex), currentValue);
                 ++childIndex;
             }
         } else {
index 3aa2bba..de73777 100644 (file)
@@ -52,7 +52,7 @@ static const StyleProperties& leftToRightDeclaration()
     static NeverDestroyed<Ref<MutableStyleProperties>> leftToRightDecl(MutableStyleProperties::create());
     if (leftToRightDecl.get()->isEmpty())
         leftToRightDecl.get()->setProperty(CSSPropertyDirection, CSSValueLtr);
-    return leftToRightDecl.get().get();
+    return leftToRightDecl.get();
 }
 
 static const StyleProperties& rightToLeftDeclaration()
@@ -60,7 +60,7 @@ static const StyleProperties& rightToLeftDeclaration()
     static NeverDestroyed<Ref<MutableStyleProperties>> rightToLeftDecl(MutableStyleProperties::create());
     if (rightToLeftDecl.get()->isEmpty())
         rightToLeftDecl.get()->setProperty(CSSPropertyDirection, CSSValueRtl);
-    return rightToLeftDecl.get().get();
+    return rightToLeftDecl.get();
 }
 
 class MatchRequest {
index 6ec0922..c2af71b 100644 (file)
@@ -1979,7 +1979,7 @@ static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSiz
 
         ++currentNamedGridLine;
         GridTrackSize trackSize;
-        if (!createGridTrackSize(currentValue.get(), trackSize, state))
+        if (!createGridTrackSize(currentValue, trackSize, state))
             return false;
 
         trackSizes.append(trackSize);
index dd9d3bd..a24d924 100644 (file)
@@ -110,7 +110,7 @@ public:
     ~StyleRule();
 
     const CSSSelectorList& selectorList() const { return m_selectorList; }
-    const StyleProperties& properties() const { return m_properties.get(); }
+    const StyleProperties& properties() const { return m_properties; }
     MutableStyleProperties& mutableProperties();
     
     void parserAdoptSelectorVector(Vector<std::unique_ptr<CSSParserSelector>>& selectors) { m_selectorList.adoptSelectorVector(selectors); }
@@ -145,7 +145,7 @@ public:
     
     ~StyleRuleFontFace();
 
-    const StyleProperties& properties() const { return m_properties.get(); }
+    const StyleProperties& properties() const { return m_properties; }
     MutableStyleProperties& mutableProperties();
 
     PassRef<StyleRuleFontFace> copy() const { return adoptRef(*new StyleRuleFontFace(*this)); }
@@ -165,7 +165,7 @@ public:
     ~StyleRulePage();
 
     const CSSSelector* selector() const { return m_selectorList.first(); }    
-    const StyleProperties& properties() const { return m_properties.get(); }
+    const StyleProperties& properties() const { return m_properties; }
     MutableStyleProperties& mutableProperties();
 
     void parserAdoptSelectorVector(Vector<std::unique_ptr<CSSParserSelector>>& selectors) { m_selectorList.adoptSelectorVector(selectors); }
index 9b0ec44..d51a32f 100644 (file)
@@ -49,7 +49,7 @@ public:
 
     void getKeys(Vector<double>& keys) const   { parseKeyString(m_key, keys); }
     
-    const StyleProperties& properties() const { return m_properties.get(); }
+    const StyleProperties& properties() const { return m_properties; }
     MutableStyleProperties& mutableProperties();
     
     String cssText() const;
index 9b16c6b..cb5c2b0 100644 (file)
@@ -85,7 +85,7 @@ void ChildListMutationAccumulator::childAdded(Node& childRef)
 
     Ref<Node> child(childRef);
 
-    if (!isAddedNodeInOrder(child.get()))
+    if (!isAddedNodeInOrder(child))
         enqueueMutationRecord();
 
     if (isEmpty()) {
@@ -108,7 +108,7 @@ void ChildListMutationAccumulator::willRemoveChild(Node& childRef)
 
     Ref<Node> child(childRef);
 
-    if (!m_addedNodes.isEmpty() || !isRemovedNodeInOrder(child.get()))
+    if (!m_addedNodes.isEmpty() || !isRemovedNodeInOrder(child))
         enqueueMutationRecord();
 
     if (isEmpty()) {
@@ -128,7 +128,7 @@ void ChildListMutationAccumulator::enqueueMutationRecord()
 
     RefPtr<NodeList> addedNodes = StaticNodeList::adopt(m_addedNodes);
     RefPtr<NodeList> removedNodes = StaticNodeList::adopt(m_removedNodes);
-    RefPtr<MutationRecord> record = MutationRecord::createChildList(m_target.get(), addedNodes.release(), removedNodes.release(), m_previousSibling.release(), m_nextSibling.release());
+    RefPtr<MutationRecord> record = MutationRecord::createChildList(m_target, addedNodes.release(), removedNodes.release(), m_previousSibling.release(), m_nextSibling.release());
     m_observers->enqueueMutationRecord(record.release());
     m_lastAdded = 0;
     ASSERT(isEmpty());
index e0c1665..b693bcd 100644 (file)
@@ -91,7 +91,7 @@ Node* ChildNodeList::namedItem(const AtomicString& name) const
         if (!element || !m_parent.get().treeScope().containsMultipleElementsWithId(name))
             return nullptr;
     }
-    for (auto& element : childrenOfType<Element>(m_parent.get())) {
+    for (auto& element : childrenOfType<Element>(m_parent)) {
         if (element.hasID() && element.idForStyleResolution() == name)
             return const_cast<Element*>(&element);
     }
index b19fca8..7e923ee 100644 (file)
@@ -41,7 +41,7 @@ public:
     }
     virtual ~EmptyNodeList();
 
-    Node& ownerNode() { return m_owner.get(); }
+    Node& ownerNode() { return m_owner; }
 
 private:
     explicit EmptyNodeList(Node& owner) : m_owner(owner) { }
@@ -65,7 +65,7 @@ public:
 
     virtual ~ChildNodeList();
 
-    ContainerNode& ownerNode() { return m_parent.get(); }
+    ContainerNode& ownerNode() { return m_parent; }
 
     void invalidateCache();
 
index 11fe96b..29c6bee 100644 (file)
@@ -115,8 +115,8 @@ void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
 
     if (oldParent->document().hasMutationObserversOfType(MutationObserver::ChildList)) {
         ChildListMutationScope mutation(*oldParent);
-        for (unsigned i = 0; i < children.size(); ++i)
-            mutation.willRemoveChild(children[i].get());
+        for (auto& child : children)
+            mutation.willRemoveChild(child);
     }
 
     // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each child,
@@ -124,13 +124,11 @@ void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
 
     oldParent->removeDetachedChildren();
 
-    for (unsigned i = 0; i < children.size(); ++i) {
-        Node& child = children[i].get();
-
+    for (auto& child : children) {
         destroyRenderTreeIfNeeded(child);
 
         // FIXME: We need a no mutation event version of adoptNode.
-        RefPtr<Node> adoptedChild = document().adoptNode(&children[i].get(), ASSERT_NO_EXCEPTION);
+        RefPtr<Node> adoptedChild = document().adoptNode(&child.get(), ASSERT_NO_EXCEPTION);
         parserAppendChild(adoptedChild.get());
         // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
         // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
@@ -299,7 +297,7 @@ bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
 
         treeScope().adoptIfNeeded(&child);
 
-        insertBeforeCommon(next.get(), child);
+        insertBeforeCommon(next, child);
 
         updateTreeAfterInsertion(child);
     }
@@ -549,7 +547,7 @@ bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec)
         return false;
     }
 
-    willRemoveChild(child.get());
+    willRemoveChild(child);
 
     // Mutation events might have moved this child into a different parent.
     if (child->parentNode() != this) {
@@ -562,11 +560,11 @@ bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec)
 
         Node* prev = child->previousSibling();
         Node* next = child->nextSibling();
-        removeBetween(prev, next, child.get());
+        removeBetween(prev, next, child);
 
-        notifyChildRemoved(child.get(), prev, next, ChildChangeSourceAPI);
+        notifyChildRemoved(child, prev, next, ChildChangeSourceAPI);
 
-        ChildNodeRemovalNotifier(*this).notify(child.get());
+        ChildNodeRemovalNotifier(*this).notify(child);
     }
 
 
@@ -663,8 +661,8 @@ void ContainerNode::removeChildren()
         ChildChange change = { AllChildrenRemoved, nullptr, nullptr, ChildChangeSourceAPI };
         childrenChanged(change);
         
-        for (size_t i = 0; i < removedChildren.size(); ++i)
-            ChildNodeRemovalNotifier(*this).notify(removedChildren[i].get());
+        for (auto& removedChild : removedChildren)
+            ChildNodeRemovalNotifier(*this).notify(removedChild);
     }
 
     if (document().svgExtensions()) {
index 37c9467..992da2c 100644 (file)
@@ -167,12 +167,13 @@ void disconnectSubframes(ContainerNode& root, SubframeDisconnectPolicy policy)
     // insert more frames and create loaded frames in detached subtrees.
     SubframeLoadingDisabler disabler(root);
 
-    for (unsigned i = 0; i < frameOwners.size(); ++i) {
-        auto& owner = frameOwners[i].get();
+    bool isFirst = true;
+    for (auto& owner : frameOwners) {
         // Don't need to traverse up the tree for the first owner since no
         // script could have moved it.
-        if (!i || root.containsIncludingShadowDOM(&owner))
-            owner.disconnectContentFrame();
+        if (isFirst || root.containsIncludingShadowDOM(&owner.get()))
+            owner.get().disconnectContentFrame();
+        isFirst = false;
     }
 }
 
index 31b32f5..0e6a5ba 100644 (file)
@@ -1364,7 +1364,7 @@ void Node::setTextContent(const String& text, ExceptionCode& ec)
         case ENTITY_REFERENCE_NODE:
         case DOCUMENT_FRAGMENT_NODE: {
             Ref<ContainerNode> container(downcast<ContainerNode>(*this));
-            ChildListMutationScope mutation(container.get());
+            ChildListMutationScope mutation(container);
             container->removeChildren();
             if (!text.isEmpty())
                 container->appendChild(document().createTextNode(text), ec);
index e310da4..7857fd9 100644 (file)
@@ -1051,8 +1051,8 @@ void ApplyStyleCommand::pushDownInlineStyleAroundNode(EditingStyle* style, Node*
 
         // The inner loop will go through children on each level
         // FIXME: we should aggregate inline child elements together so that we don't wrap each child separately.
-        for (size_t i = 0; i < currentChildren.size(); ++i) {
-            Node& child = currentChildren[i].get();
+        for (Ref<Node>& childRef : currentChildren) {
+            Node& child = childRef;
             if (!child.parentNode())
                 continue;
             if (!child.contains(targetNode) && elementsToPushDown.size()) {
index 0b65c1f..03e6c37 100644 (file)
@@ -64,7 +64,7 @@ protected:
     EditCommand(Document&, const VisibleSelection&, const VisibleSelection&);
 
     Frame& frame();
-    Document& document() { return m_document.get(); }
+    Document& document() { return m_document; }
     CompositeEditCommand* parent() const { return m_parent; }
     void setStartingSelection(const VisibleSelection&);
     WEBCORE_EXPORT void setEndingSelection(const VisibleSelection&);
index 6e08951..84a8dd1 100644 (file)
@@ -1221,7 +1221,7 @@ bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectIn
                     options |= TypingCommand::SelectInsertedText;
                 if (autocorrectionWasApplied)
                     options |= TypingCommand::RetainAutocorrectionIndicator;
-                TypingCommand::insertText(document.get(), text, selection, options, triggeringEvent && triggeringEvent->isComposition() ? TypingCommand::TextCompositionConfirm : TypingCommand::TextCompositionNone);
+                TypingCommand::insertText(document, text, selection, options, triggeringEvent && triggeringEvent->isComposition() ? TypingCommand::TextCompositionConfirm : TypingCommand::TextCompositionNone);
             }
 
             // Reveal the current selection
index bb760cc..9f27984 100644 (file)
@@ -563,7 +563,7 @@ HTMLConverter::~HTMLConverter()
 
 NSAttributedString *HTMLConverter::convert()
 {
-    Node* commonAncestorContainer = _caches->cacheAncestorsOfStartToBeConverted(m_range.get());
+    Node* commonAncestorContainer = _caches->cacheAncestorsOfStartToBeConverted(m_range);
     ASSERT(commonAncestorContainer);
 
     m_dataSource = commonAncestorContainer->document().frame()->loader().documentLoader();
index 0e8ff83..41d6d59 100644 (file)
@@ -957,25 +957,25 @@ PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, HTML
     ASSERT(element);
     if (element->ieForbidsInsertHTML()) {
         ec = NOT_SUPPORTED_ERR;
-        return 0;
+        return nullptr;
     }
 
     if (element->hasTagName(colTag) || element->hasTagName(colgroupTag) || element->hasTagName(framesetTag)
         || element->hasTagName(headTag) || element->hasTagName(styleTag) || element->hasTagName(titleTag)) {
         ec = NOT_SUPPORTED_ERR;
-        return 0;
+        return nullptr;
     }
 
     RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, element, parserContentPolicy, ec);
     if (!fragment)
-        return 0;
+        return nullptr;
 
     // We need to pop <html> and <body> elements and remove <head> to
     // accommodate folks passing complete HTML documents to make the
     // child of an element.
     auto toRemove = collectElementsToRemoveFromFragment(*fragment);
-    for (unsigned i = 0; i < toRemove.size(); ++i)
-        removeElementFromFragmentPreservingChildren(*fragment, toRemove[i].get());
+    for (auto& element : toRemove)
+        removeElementFromFragmentPreservingChildren(*fragment, element);
 
     return fragment.release();
 }
@@ -994,7 +994,7 @@ static inline bool hasOneTextChild(ContainerNode* node)
 void replaceChildrenWithFragment(ContainerNode& container, PassRefPtr<DocumentFragment> fragment, ExceptionCode& ec)
 {
     Ref<ContainerNode> containerNode(container);
-    ChildListMutationScope mutation(containerNode.get());
+    ChildListMutationScope mutation(containerNode);
 
     if (!fragment->firstChild()) {
         containerNode->removeChildren();
@@ -1018,7 +1018,7 @@ void replaceChildrenWithFragment(ContainerNode& container, PassRefPtr<DocumentFr
 void replaceChildrenWithText(ContainerNode& container, const String& text, ExceptionCode& ec)
 {
     Ref<ContainerNode> containerNode(container);
-    ChildListMutationScope mutation(containerNode.get());
+    ChildListMutationScope mutation(containerNode);
 
     if (hasOneTextChild(&containerNode.get())) {
         downcast<Text>(*containerNode->firstChild()).setData(text, ec);
index a4a77aa..6bfb16e 100644 (file)
@@ -47,8 +47,8 @@ namespace WebCore {
             return adoptRef(new CanvasGradient(p0, r0, p1, r1));
         }
         
-        Gradient& gradient() { return m_gradient.get(); }
-        const Gradient& gradient() const { return m_gradient.get(); }
+        Gradient& gradient() { return m_gradient; }
+        const Gradient& gradient() const { return m_gradient; }
 
         void addColorStop(float value, const String& color, ExceptionCode&);
 
index 0ea0bc9..853ce26 100644 (file)
@@ -45,8 +45,8 @@ public:
 
     static void parseRepetitionType(const String&, bool& repeatX, bool& repeatY, ExceptionCode&);
 
-    Pattern& pattern() { return m_pattern.get(); }
-    const Pattern& pattern() const { return m_pattern.get(); }
+    Pattern& pattern() { return m_pattern; }
+    const Pattern& pattern() const { return m_pattern; }
 
     bool originClean() const { return m_originClean; }
 
index 403e195..c1df9fc 100644 (file)
@@ -103,7 +103,7 @@ namespace WebCore {
         WEBCORE_EXPORT const ResourceRequest& request() const;
         WEBCORE_EXPORT ResourceRequest& request();
 
-        CachedResourceLoader& cachedResourceLoader() { return m_cachedResourceLoader.get(); }
+        CachedResourceLoader& cachedResourceLoader() { return m_cachedResourceLoader; }
 
         const SubstituteData& substituteData() const { return m_substituteData; }
 
index fc8bb16..675b76a 100644 (file)
@@ -3286,8 +3286,8 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
 
     Vector<Ref<DOMWrapperWorld>> worlds;
     ScriptController::getAllWorlds(worlds);
-    for (size_t i = 0; i < worlds.size(); ++i)
-        dispatchDidClearWindowObjectInWorld(worlds[i].get());
+    for (auto& world : worlds)
+        dispatchDidClearWindowObjectInWorld(world);
 }
 
 void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& world)
@@ -3309,8 +3309,8 @@ void FrameLoader::dispatchGlobalObjectAvailableInAllWorlds()
 {
     Vector<Ref<DOMWrapperWorld>> worlds;
     ScriptController::getAllWorlds(worlds);
-    for (size_t i = 0; i < worlds.size(); ++i)
-        m_client.dispatchGlobalObjectAvailable(worlds[i].get());
+    for (auto& world : worlds)
+        m_client.dispatchGlobalObjectAvailable(world);
 }
 
 SandboxFlags FrameLoader::effectiveSandboxFlags() const
index 08bf909..fbc31d2 100644 (file)
@@ -254,8 +254,8 @@ bool DOMWindow::dispatchAllPendingBeforeUnloadEvents()
     for (auto it = set.begin(), end = set.end(); it != end; ++it)
         windows.uncheckedAppend(*it->key);
 
-    for (unsigned i = 0; i < windows.size(); ++i) {
-        DOMWindow& window = windows[i].get();
+    for (Ref<DOMWindow>& windowRef : windows) {
+        DOMWindow& window = windowRef;
         if (!set.contains(&window))
             continue;
 
@@ -291,11 +291,11 @@ void DOMWindow::dispatchAllPendingUnloadEvents()
 
     Vector<Ref<DOMWindow>> windows;
     windows.reserveInitialCapacity(set.size());
-    for (auto it = set.begin(), end = set.end(); it != end; ++it)
-        windows.uncheckedAppend(*it->key);
+    for (auto& keyValue : set)
+        windows.uncheckedAppend(*keyValue.key);
 
-    for (unsigned i = 0; i < windows.size(); ++i) {
-        DOMWindow& window = windows[i].get();
+    for (Ref<DOMWindow>& windowRef : windows) {
+        DOMWindow& window = windowRef;
         if (!set.contains(&window))
             continue;
 
index 732c981..1a7cd2a 100644 (file)
@@ -516,7 +516,7 @@ PassRef<RenderStyle> AnimationController::updateAnimations(RenderElement& render
     Ref<RenderStyle> newStyleBeforeAnimation(WTF::move(newStyle));
 
     CompositeAnimation& rendererAnimations = m_data->ensureCompositeAnimation(renderer);
-    auto blendedStyle = rendererAnimations.animate(renderer, oldStyle, newStyleBeforeAnimation.get());
+    auto blendedStyle = rendererAnimations.animate(renderer, oldStyle, newStyleBeforeAnimation);
 
     if (renderer.parent() || newStyleBeforeAnimation->animations() || (oldStyle && oldStyle->animations())) {
         m_data->updateAnimationTimerForRenderer(renderer);
index 926aa5c..a2b62db 100644 (file)
@@ -48,7 +48,7 @@ TileCoverageMap::TileCoverageMap(const TileController& controller)
     m_visibleRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
     m_visibleRectIndicatorLayer.get().setBorderColor(Color(255, 0, 0));
 
-    m_layer.get().appendSublayer(m_visibleRectIndicatorLayer.get());
+    m_layer.get().appendSublayer(m_visibleRectIndicatorLayer);
 
     update();
 }
index 04e3c25..2b98afc 100644 (file)
@@ -50,7 +50,7 @@ public:
     void update();
     void setPosition(const FloatPoint& position) { m_position = position; }
 
-    PlatformCALayer& layer() { return m_layer.get(); }
+    PlatformCALayer& layer() { return m_layer; }
 
     void setDeviceScaleFactor(float);
 
index bb0a58c..18fb326 100644 (file)
@@ -51,7 +51,7 @@ public:
     TileGrid(TileController&);
     ~TileGrid();
 
-    PlatformCALayer& containerLayer() { return m_containerLayer.get(); }
+    PlatformCALayer& containerLayer() { return m_containerLayer; }
 
     void setScale(float);
     float scale() const { return m_scale; }
index e7231e6..b9e7024 100644 (file)
@@ -101,7 +101,7 @@ public:
         return adoptRef(new ShapeClipPathOperation(WTF::move(shape)));
     }
 
-    const BasicShape& basicShape() const { return m_shape.get(); }
+    const BasicShape& basicShape() const { return m_shape; }
     WindRule windRule() const { return m_shape.get().windRule(); }
     const Path pathForReferenceRect(const FloatRect& boundingRect)
     {
index d873f1b..734d02e 100644 (file)
@@ -128,8 +128,8 @@ private:
     void clearContentElements();
     void updateWritingMode();
 
-    WebKitNamedFlow& namedFlow() { return m_namedFlow.get(); }
-    const WebKitNamedFlow& namedFlow() const { return m_namedFlow.get(); }
+    WebKitNamedFlow& namedFlow() { return m_namedFlow; }
+    const WebKitNamedFlow& namedFlow() const { return m_namedFlow; }
 
     // Observer flow threads have invalid regions that depend on the state of this thread
     // to re-validate their regions. Keeping a set of observer threads make it easy
index 1dbd238..7cd08be 100644 (file)
@@ -38,7 +38,7 @@ public:
         return adoptRef(new StyleGeneratedImage(WTF::move(value)));
     }
 
-    CSSImageGeneratorValue& imageValue() { return m_imageGeneratorValue.get(); }
+    CSSImageGeneratorValue& imageValue() { return m_imageGeneratorValue; }
 
 private:
     virtual WrappedImagePtr data() const override { return &m_imageGeneratorValue.get(); }
index 06dc1df..26426f5 100644 (file)
@@ -1,3 +1,13 @@
+2014-11-03  Chris Dumez  <cdumez@apple.com>
+
+        Allow implicit conversion from Ref<T> to T&
+        https://bugs.webkit.org/show_bug.cgi?id=138331
+
+        Reviewed by Andreas Kling.
+
+        Remove unnecessary calls to Ref<T>::get() now that a Ref<T> can be
+        converted implicitly to a T&.
+
 2014-11-03  Simon Fraser  <simon.fraser@apple.com>
 
         Expose visibleDebugOverlayRegions pref via the WK2 C SPI
index 622d123..f149730 100644 (file)
@@ -375,7 +375,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     if (m_process->state() == WebProcessProxy::State::Running) {
         if (m_userContentController)
             m_process->addWebUserContentControllerProxy(*m_userContentController);
-        m_process->addVisitedLinkProvider(m_visitedLinkProvider.get());
+        m_process->addVisitedLinkProvider(m_visitedLinkProvider);
     }
 
     updateViewState();
@@ -3169,7 +3169,7 @@ void WebPageProxy::processDidFinishLaunching()
 
     if (m_userContentController)
         m_process->addWebUserContentControllerProxy(*m_userContentController);
-    m_process->addVisitedLinkProvider(m_visitedLinkProvider.get());
+    m_process->addVisitedLinkProvider(m_visitedLinkProvider);
 }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
index 5953200..92a31a3 100644 (file)
@@ -255,7 +255,7 @@ public:
     RemoteScrollingCoordinatorProxy* scrollingCoordinatorProxy() const { return m_scrollingCoordinatorProxy.get(); }
 #endif
 
-    WebBackForwardList& backForwardList() { return m_backForwardList.get(); }
+    WebBackForwardList& backForwardList() { return m_backForwardList; }
 
     bool addsVisitedLinks() const { return m_addsVisitedLinks; }
     void setAddsVisitedLinks(bool addsVisitedLinks) { m_addsVisitedLinks = addsVisitedLinks; }
@@ -738,13 +738,13 @@ public:
     bool isValidKeypressCommandName(const String& name) const { return m_knownKeypressCommandNames.contains(name); }
 #endif
 
-    WebProcessProxy& process() { return m_process.get(); }
+    WebProcessProxy& process() { return m_process; }
     PlatformProcessIdentifier processIdentifier() const;
 
-    WebPreferences& preferences() { return m_preferences.get(); }
+    WebPreferences& preferences() { return m_preferences; }
     void setPreferences(WebPreferences&);
 
-    WebPageGroup& pageGroup() { return m_pageGroup.get(); }
+    WebPageGroup& pageGroup() { return m_pageGroup; }
 
     bool isValid() const;
 
index b20c071..884ec44 100644 (file)
@@ -616,7 +616,7 @@ DownloadProxy* WebProcessProxy::createDownloadProxy(const ResourceRequest& reque
     if (!m_downloadProxyMap)
         m_downloadProxyMap = std::make_unique<DownloadProxyMap>(this);
 
-    return m_downloadProxyMap->createDownloadProxy(m_context.get(), request);
+    return m_downloadProxyMap->createDownloadProxy(m_context, request);
 }
 
 void WebProcessProxy::didNavigateWithNavigationData(uint64_t pageID, const WebNavigationDataStore& store, uint64_t frameID) 
index b63f6e3..6c74026 100644 (file)
@@ -78,7 +78,7 @@ public:
 
     WebConnection* webConnection() const { return m_webConnection.get(); }
 
-    WebContext& context() { return m_context.get(); }
+    WebContext& context() { return m_context; }
 
     static WebPageProxy* webPage(uint64_t pageID);
     PassRefPtr<WebPageProxy> createWebPage(PageClient&, const WebPageConfiguration&);
index 639c20e..c25c2e8 100644 (file)
@@ -41,7 +41,7 @@ public:
     static PassRefPtr<WebUserContentController> getOrCreate(uint64_t identifier);
     virtual ~WebUserContentController();
 
-    WebCore::UserContentController& userContentController() { return m_userContentController.get(); }
+    WebCore::UserContentController& userContentController() { return m_userContentController; }
 
     uint64_t identifier() { return m_identifier; }