Title: [94009] trunk/Source/WebCore
Revision
94009
Author
[email protected]
Date
2011-08-29 13:18:46 -0700 (Mon, 29 Aug 2011)

Log Message

Cleanup: notifyFormStateChanged, formControlValueMatchesRenderer, and setFormControlValueMatchesRenderer
https://bugs.webkit.org/show_bug.cgi?id=67141

Reviewed by Eric Seidel.

No new tests since this is a refactoring.

* dom/Element.h: Removed formControlValueMatchesRenderer and setFormControlValueMatchesRenderer.
* html/HTMLInputElement.cpp: Removed notifyFormStateChanged.
* html/HTMLInputElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::updateValue): Calls notifyFormStateChanged; modifies m_wasModifiedByUser.
(WebCore::HTMLTextAreaElement::setValueCommon): Calls notifyFormStateChanged; also renamed value to newValue
to avoid the conflict with value().
* html/HTMLTextAreaElement.h: Made m_wasModifiedByUser mutable.
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::notifyFormStateChanged): Extracted from notifyFormStateChanged in
HTMLInputElement.cpp and HTMLTextAreaElement.cpp.
* html/HTMLTextFormControlElement.h:
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::setInnerTextValue): Calls setFormControlValueMatchesRenderer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (94008 => 94009)


--- trunk/Source/WebCore/ChangeLog	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/ChangeLog	2011-08-29 20:18:46 UTC (rev 94009)
@@ -1,3 +1,27 @@
+2011-08-29  Ryosuke Niwa  <[email protected]>
+
+        Cleanup: notifyFormStateChanged, formControlValueMatchesRenderer, and setFormControlValueMatchesRenderer
+        https://bugs.webkit.org/show_bug.cgi?id=67141
+
+        Reviewed by Eric Seidel.
+
+        No new tests since this is a refactoring.
+
+        * dom/Element.h: Removed formControlValueMatchesRenderer and setFormControlValueMatchesRenderer.
+        * html/HTMLInputElement.cpp: Removed notifyFormStateChanged.
+        * html/HTMLInputElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::updateValue): Calls notifyFormStateChanged; modifies m_wasModifiedByUser.
+        (WebCore::HTMLTextAreaElement::setValueCommon): Calls notifyFormStateChanged; also renamed value to newValue
+        to avoid the conflict with value().
+        * html/HTMLTextAreaElement.h: Made m_wasModifiedByUser mutable.
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::notifyFormStateChanged): Extracted from notifyFormStateChanged in
+        HTMLInputElement.cpp and HTMLTextAreaElement.cpp.
+        * html/HTMLTextFormControlElement.h:
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::setInnerTextValue): Calls setFormControlValueMatchesRenderer.
+
 2011-08-29  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r93987, r93992, r93995, r93998, and

Modified: trunk/Source/WebCore/dom/Element.h (94008 => 94009)


--- trunk/Source/WebCore/dom/Element.h	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/dom/Element.h	2011-08-29 20:18:46 UTC (rev 94009)
@@ -337,9 +337,6 @@
 
     virtual bool canContainRangeEndPoint() const { return true; }
 
-    virtual bool formControlValueMatchesRenderer() const { return false; }
-    virtual void setFormControlValueMatchesRenderer(bool) { }
-
     virtual const AtomicString& formControlName() const { return nullAtom; }
     virtual const AtomicString& formControlType() const { return nullAtom; }
 

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (94008 => 94009)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-08-29 20:18:46 UTC (rev 94009)
@@ -29,10 +29,7 @@
 #include "HTMLInputElement.h"
 
 #include "AXObjectCache.h"
-#include "Attribute.h"
 #include "BeforeTextInsertedEvent.h"
-#include "Chrome.h"
-#include "ChromeClient.h"
 #include "CSSPropertyNames.h"
 #include "Document.h"
 #include "EventNames.h"
@@ -45,14 +42,11 @@
 #include "HTMLNames.h"
 #include "HTMLOptionElement.h"
 #include "HTMLParserIdioms.h"
-#include "Icon.h"
 #include "InputType.h"
 #include "KeyboardEvent.h"
 #include "LocalizedStrings.h"
 #include "MouseEvent.h"
 #include "NumberInputType.h"
-#include "Page.h"
-#include "PlatformMouseEvent.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
 #include "RuntimeEnabledFeatures.h"
@@ -1909,16 +1903,6 @@
     return document()->checkedRadioButtons();
 }
 
-void HTMLInputElement::notifyFormStateChanged()
-{
-    Frame* frame = document()->frame();
-    if (!frame)
-        return;
-
-    if (Page* page = frame->page())
-        page->chrome()->client()->formStateDidChange(this);
-}
-
 void HTMLInputElement::parseMaxLengthAttribute(Attribute* attribute)
 {
     int maxLength;

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (94008 => 94009)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2011-08-29 20:18:46 UTC (rev 94009)
@@ -229,7 +229,6 @@
 #endif
 
     bool lastChangeWasUserEdit() const;
-    void notifyFormStateChanged();
 
     static const int maximumLength;
 

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (94008 => 94009)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2011-08-29 20:18:46 UTC (rev 94009)
@@ -29,25 +29,19 @@
 #include "Attribute.h"
 #include "BeforeTextInsertedEvent.h"
 #include "CSSValueKeywords.h"
-#include "Chrome.h"
-#include "ChromeClient.h"
 #include "Document.h"
 #include "Event.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
-#include "FocusController.h"
 #include "FormDataList.h"
 #include "Frame.h"
 #include "HTMLNames.h"
-#include "Page.h"
 #include "RenderStyle.h"
 #include "RenderTextControlMultiLine.h"
-#include "ScriptEventListener.h"
 #include "ShadowRoot.h"
 #include "Text.h"
 #include "TextControlInnerElements.h"
 #include "TextIterator.h"
-#include "VisibleSelection.h"
 #include <wtf/StdLibExtras.h>
 
 namespace WebCore {
@@ -57,14 +51,6 @@
 static const int defaultRows = 2;
 static const int defaultCols = 20;
 
-static inline void notifyFormStateChanged(const HTMLTextAreaElement* element)
-{
-    Frame* frame = element->document()->frame();
-    if (!frame)
-        return;
-    frame->page()->chrome()->client()->formStateDidChange(element);
-}
-
 HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
     : HTMLTextFormControlElement(tagName, document, form)
     , m_rows(defaultRows)
@@ -306,9 +292,9 @@
     ASSERT(renderer());
     m_value = toRenderTextControl(renderer())->text();
     const_cast<HTMLTextAreaElement*>(this)->setFormControlValueMatchesRenderer(true);
-    notifyFormStateChanged(this);
+    const_cast<HTMLTextAreaElement*>(this)->notifyFormStateChanged();
     m_isDirty = true;
-    const_cast<HTMLTextAreaElement*>(this)->m_wasModifiedByUser = true;
+    m_wasModifiedByUser = true;
     const_cast<HTMLTextAreaElement*>(this)->updatePlaceholderVisibility(false);
 }
 
@@ -332,18 +318,18 @@
     setNeedsValidityCheck();
 }
 
-void HTMLTextAreaElement::setValueCommon(const String& value)
+void HTMLTextAreaElement::setValueCommon(const String& newValue)
 {
     m_wasModifiedByUser = false;
     // Code elsewhere normalizes line endings added by the user via the keyboard or pasting.
     // We normalize line endings coming from _javascript_ here.
-    String normalizedValue = value.isNull() ? "" : value;
+    String normalizedValue = newValue.isNull() ? "" : newValue;
     normalizedValue.replace("\r\n", "\n");
     normalizedValue.replace('\r', '\n');
 
     // Return early because we don't want to move the caret or trigger other side effects
     // when the value isn't changing. This matches Firefox behavior, at least.
-    if (normalizedValue == this->value())
+    if (normalizedValue == value())
         return;
 
     m_value = normalizedValue;
@@ -357,7 +343,7 @@
         setSelectionRange(endOfString, endOfString);
     }
 
-    notifyFormStateChanged(this);
+    notifyFormStateChanged();
     setTextAsOfLastFormControlChangeEvent(normalizedValue);
 }
 

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (94008 => 94009)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2011-08-29 20:18:46 UTC (rev 94009)
@@ -113,7 +113,7 @@
     RefPtr<HTMLElement> m_placeholder;
     mutable String m_value;
     mutable bool m_isDirty;
-    bool m_wasModifiedByUser;
+    mutable bool m_wasModifiedByUser;
 };
 
 } //namespace

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (94008 => 94009)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2011-08-29 20:18:46 UTC (rev 94009)
@@ -26,6 +26,8 @@
 #include "HTMLTextFormControlElement.h"
 
 #include "Attribute.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
 #include "Document.h"
 #include "Event.h"
 #include "EventNames.h"
@@ -33,6 +35,7 @@
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
+#include "Page.h"
 #include "RenderBox.h"
 #include "RenderTextControl.h"
 #include "RenderTheme.h"
@@ -433,6 +436,16 @@
         HTMLFormControlElementWithState::parseMappedAttribute(attr);
 }
 
+void HTMLTextFormControlElement::notifyFormStateChanged()
+{
+    Frame* frame = document()->frame();
+    if (!frame)
+        return;
+    
+    if (Page* page = frame->page())
+        page->chrome()->client()->formStateDidChange(this);
+}
+
 HTMLTextFormControlElement* enclosingTextFormControl(const Position& position)
 {
     ASSERT(position.isNull() || position.anchorType() == Position::PositionIsOffsetInAnchor

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (94008 => 94009)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2011-08-29 20:18:46 UTC (rev 94009)
@@ -74,6 +74,7 @@
     virtual HTMLElement* innerTextElement() const = 0;
 
     void selectionChanged(bool userTriggered);
+    void notifyFormStateChanged();
 
 protected:
     HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (94008 => 94009)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2011-08-29 20:16:50 UTC (rev 94008)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2011-08-29 20:18:46 UTC (rev 94009)
@@ -171,7 +171,7 @@
         m_lastChangeWasUserEdit = false;
     }
 
-    static_cast<Element*>(node())->setFormControlValueMatchesRenderer(true);
+    textFormControlElement()->setFormControlValueMatchesRenderer(true);
 }
 
 VisiblePosition RenderTextControl::visiblePositionForIndex(int index) const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to