Remove RefPtr from HTMLTextAreaElement::m_placeholder
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2012 10:08:49 +0000 (10:08 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2012 10:08:49 +0000 (10:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94338

Reviewed by Kent Tamura.

To avoid reference cycles of RefPtr<Node>s, we want to remove
unnecessary RefPtr<Node>s. The rationale is described in bug 94324.

HTMLTextAreaElement::m_placeholder does not need to be a RefPtr<Node>,
because it is guaranteed to point to a shadow DOM tree of the
HTMLTextAreaElement node, which is guaranteed to exist in the subtree
of the HTMLTextAreaElement node.

No tests. No change in behavior.

* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::HTMLTextAreaElement):
(WebCore::HTMLTextAreaElement::placeholderElement):
(WebCore::HTMLTextAreaElement::attach):
(WebCore::HTMLTextAreaElement::updatePlaceholderText):
* html/HTMLTextAreaElement.h:
(HTMLTextAreaElement):

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLTextAreaElement.h

index 3f78741..a919b2d 100644 (file)
@@ -1,3 +1,28 @@
+2012-08-24  Kentaro Hara  <haraken@chromium.org>
+
+        Remove RefPtr from HTMLTextAreaElement::m_placeholder
+        https://bugs.webkit.org/show_bug.cgi?id=94338
+
+        Reviewed by Kent Tamura.
+
+        To avoid reference cycles of RefPtr<Node>s, we want to remove
+        unnecessary RefPtr<Node>s. The rationale is described in bug 94324.
+
+        HTMLTextAreaElement::m_placeholder does not need to be a RefPtr<Node>,
+        because it is guaranteed to point to a shadow DOM tree of the
+        HTMLTextAreaElement node, which is guaranteed to exist in the subtree
+        of the HTMLTextAreaElement node.
+
+        No tests. No change in behavior.
+
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::HTMLTextAreaElement):
+        (WebCore::HTMLTextAreaElement::placeholderElement):
+        (WebCore::HTMLTextAreaElement::attach):
+        (WebCore::HTMLTextAreaElement::updatePlaceholderText):
+        * html/HTMLTextAreaElement.h:
+        (HTMLTextAreaElement):
+
 2012-08-24  Dan Carney  <dcarney@google.com>
 
         [V8] Refactor away IsolatedWorld
index bad8571..7282a5c 100644 (file)
@@ -72,6 +72,7 @@ HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document*
     , m_rows(defaultRows)
     , m_cols(defaultCols)
     , m_wrap(SoftWrap)
+    , m_placeholder(0)
     , m_isDirty(false)
     , m_wasModifiedByUser(false)
 {
@@ -490,13 +491,13 @@ bool HTMLTextAreaElement::shouldUseInputMethod()
 
 HTMLElement* HTMLTextAreaElement::placeholderElement() const
 {
-    return m_placeholder.get();
+    return m_placeholder;
 }
 
 void HTMLTextAreaElement::attach()
 {
     HTMLTextFormControlElement::attach();
-    fixPlaceholderRenderer(m_placeholder.get(), innerTextElement());
+    fixPlaceholderRenderer(m_placeholder, innerTextElement());
 }
 
 void HTMLTextAreaElement::updatePlaceholderText()
@@ -505,21 +506,22 @@ void HTMLTextAreaElement::updatePlaceholderText()
     String placeholderText = strippedPlaceholder();
     if (placeholderText.isEmpty()) {
         if (m_placeholder) {
-            userAgentShadowRoot()->removeChild(m_placeholder.get(), ec);
+            userAgentShadowRoot()->removeChild(m_placeholder, ec);
             ASSERT(!ec);
-            m_placeholder.clear();
+            m_placeholder = 0;
         }
         return;
     }
     if (!m_placeholder) {
-        m_placeholder = HTMLDivElement::create(document());
+        RefPtr<HTMLDivElement> placeholder = HTMLDivElement::create(document());
+        m_placeholder = placeholder.get();
         m_placeholder->setShadowPseudoId("-webkit-input-placeholder");
         userAgentShadowRoot()->insertBefore(m_placeholder, innerTextElement()->nextSibling(), ec);
         ASSERT(!ec);
     }
     m_placeholder->setInnerText(placeholderText, ec);
     ASSERT(!ec);
-    fixPlaceholderRenderer(m_placeholder.get(), innerTextElement());
+    fixPlaceholderRenderer(m_placeholder, innerTextElement());
 }
 
 }
index 4e6db56..6e2aa58 100644 (file)
@@ -117,7 +117,7 @@ private:
     int m_rows;
     int m_cols;
     WrapMethod m_wrap;
-    RefPtr<HTMLElement> m_placeholder;
+    HTMLElement* m_placeholder;
     mutable String m_value;
     mutable bool m_isDirty;
     mutable bool m_wasModifiedByUser;