Add WebKit2 API to figure out if an input or textarea was edited
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Mar 2011 18:37:42 +0000 (18:37 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Mar 2011 18:37:42 +0000 (18:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=56474

Reviewed by Adam Roben.

Source/WebCore:

Add HTMLInputElement::lastChangeWasUserEdit and HTMLTextAreaElement::lastChangeWasUserEdit
and use them to implement -[DOMHTMLInputElement _isEdited] and -[DOMHTMLTextAreaElement _isEdited]
as well as API in WebKit2.

* WebCore.exp.in:
* bindings/objc/DOMHTML.mm:
(-[DOMHTMLInputElement _isEdited]):
(-[DOMHTMLTextAreaElement _isEdited]):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::lastChangeWasUserEdit):
* html/HTMLInputElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::lastChangeWasUserEdit):
* html/HTMLTextAreaElement.h:

Source/WebKit2:

Expose WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit and
WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit. Next time,
I will work on giving these functions longer names.

* WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
(WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit):
(WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit):
* WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit):
(WebKit::InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit):
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/bindings/objc/DOMHTML.mm
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLTextAreaElement.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h

index 2237fbf..d9a5968 100644 (file)
@@ -1,3 +1,25 @@
+2011-03-16  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Adam Roben.
+
+        Add WebKit2 API to figure out if an input or textarea was edited
+        https://bugs.webkit.org/show_bug.cgi?id=56474
+
+        Add HTMLInputElement::lastChangeWasUserEdit and HTMLTextAreaElement::lastChangeWasUserEdit
+        and use them to implement -[DOMHTMLInputElement _isEdited] and -[DOMHTMLTextAreaElement _isEdited]
+        as well as API in WebKit2.
+
+        * WebCore.exp.in:
+        * bindings/objc/DOMHTML.mm:
+        (-[DOMHTMLInputElement _isEdited]):
+        (-[DOMHTMLTextAreaElement _isEdited]):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::lastChangeWasUserEdit):
+        * html/HTMLInputElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::lastChangeWasUserEdit):
+        * html/HTMLTextAreaElement.h:
+
 2011-03-15  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index f88b0de..e52a3a9 100644 (file)
@@ -1115,6 +1115,7 @@ __ZNK7WebCore15VisiblePosition4nextENS_27EditingBoundaryCrossingRuleE
 __ZNK7WebCore15VisiblePosition8previousENS_27EditingBoundaryCrossingRuleE
 __ZNK7WebCore16FontFallbackList10fontDataAtEPKNS_4FontEj
 __ZNK7WebCore16HTMLInputElement12autoCompleteEv
+__ZNK7WebCore16HTMLInputElement21lastChangeWasUserEditEv
 __ZNK7WebCore16IconDatabaseBase12databasePathEv
 __ZNK7WebCore16ResourceResponse13nsURLResponseEv
 __ZNK7WebCore16VisibleSelection17isContentEditableEv
@@ -1124,6 +1125,7 @@ __ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv
 __ZNK7WebCore16VisibleSelection5isAllENS_27EditingBoundaryCrossingRuleE
 __ZNK7WebCore17ResourceErrorBase8lazyInitEv
 __ZNK7WebCore19AnimationController24numberOfActiveAnimationsEv
+__ZNK7WebCore19HTMLTextAreaElement21lastChangeWasUserEditEv
 __ZNK7WebCore19ResourceRequestBase10httpMethodEv
 __ZNK7WebCore19ResourceRequestBase15httpHeaderFieldEPKc
 __ZNK7WebCore19ResourceRequestBase3urlEv
index a2277d2..92588e1 100644 (file)
 
 - (BOOL)_isEdited
 {
-    WebCore::RenderObject *renderer = core(self)->renderer();
-    return renderer && [self _isTextField] && static_cast<WebCore::RenderTextControl *>(renderer)->lastChangeWasUserEdit();
+    return core(self)->lastChangeWasUserEdit();
 }
 
 @end
 
 - (BOOL)_isEdited
 {
-    WebCore::RenderObject* renderer = core(self)->renderer();
-    return renderer && static_cast<WebCore::RenderTextControl*>(renderer)->lastChangeWasUserEdit();
+    return core(self)->lastChangeWasUserEdit();
 }
 
 @end
index ef25d1c..f8e29b3 100644 (file)
@@ -146,6 +146,17 @@ void HTMLInputElement::updateCheckedRadioButtons()
         renderer()->theme()->stateChanged(renderer(), CheckedState);
 }
 
+bool HTMLInputElement::lastChangeWasUserEdit() const
+{
+    if (!isTextField())
+        return false;
+    
+    if (!renderer())
+        return false;
+
+    return toRenderTextControl(renderer())->lastChangeWasUserEdit();
+}
+
 bool HTMLInputElement::isValidValue(const String& value) const
 {
     if (!m_inputType->canSetStringValue()) {
index ba80603..f2c2625 100644 (file)
@@ -199,6 +199,8 @@ public:
     void handleBeforeTextInsertedEvent(Event*);
     void updateCheckedRadioButtons();
 
+    bool lastChangeWasUserEdit() const;
+    
 protected:
     HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
 
index 4336131..2cb085c 100644 (file)
@@ -421,6 +421,13 @@ void HTMLTextAreaElement::setRows(int rows)
     setAttribute(rowsAttr, String::number(rows));
 }
 
+bool HTMLTextAreaElement::lastChangeWasUserEdit() const
+{
+    if (!renderer())
+        return false;
+    return toRenderTextControl(renderer())->lastChangeWasUserEdit();
+}
+
 bool HTMLTextAreaElement::shouldUseInputMethod() const
 {
     return true;
index 21b5880..40193a0 100644 (file)
@@ -55,7 +55,9 @@ public:
     
     void setCols(int);
     void setRows(int);
-    
+
+    bool lastChangeWasUserEdit() const;
+
     void cacheSelection(int s, int e) { m_cachedSelectionStart = s; m_cachedSelectionEnd = e; };
 
 private:
index e74f93b..b9d1453 100644 (file)
@@ -1,3 +1,23 @@
+2011-03-16  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Adam Roben.
+
+        Add WebKit2 API to figure out if an input or textarea was edited
+        https://bugs.webkit.org/show_bug.cgi?id=56474
+
+        Expose WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit and
+        WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit. Next time,
+        I will work on giving these functions longer names.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+        (WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit):
+        (WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit):
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit):
+        (WebKit::InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
+
 2011-03-16  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Adam Roben.
index 0e91d8e..6bed7a4 100644 (file)
@@ -76,6 +76,16 @@ void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlI
     toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled);
 }
 
+bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandleRef)
+{
+    return toImpl(htmlInputElementHandleRef)->htmlInputElementLastChangeWasUserEdit();
+}
+
+bool WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlTextAreaElementHandleRef)
+{
+    return toImpl(htmlTextAreaElementHandleRef)->htmlTextAreaElementLastChangeWasUserEdit();
+}
+
 WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandleRef)
 {
     RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(htmlTableCellElementHandleRef)->htmlTableCellElementCellAbove();
index aaa95e6..6006596 100644 (file)
@@ -50,7 +50,11 @@ WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandl
 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value);
 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle);
 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled);
+WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandle);
 
+/* HTMLTextAreaElement Specific Operations */
+WK_EXPORT bool WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlTextAreaElementHandle);
+    
 /* HTMLTableCellElement Specific Operations */
 WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandle);
 
index 858941e..5e15872 100644 (file)
 #include "WebFrameLoaderClient.h"
 #include <JavaScriptCore/APICast.h>
 #include <WebCore/Document.h>
+#include <WebCore/Frame.h>
 #include <WebCore/HTMLFrameElement.h>
 #include <WebCore/HTMLIFrameElement.h>
-#include <WebCore/Frame.h>
 #include <WebCore/HTMLInputElement.h>
 #include <WebCore/HTMLNames.h>
 #include <WebCore/HTMLTableCellElement.h>
+#include <WebCore/HTMLTextAreaElement.h>
 #include <WebCore/IntRect.h>
 #include <WebCore/JSNode.h>
 #include <WebCore/Node.h>
@@ -132,7 +133,6 @@ bool InjectedBundleNodeHandle::isHTMLInputElementAutofilled() const
     return static_cast<HTMLInputElement*>(m_node.get())->isAutofilled();
 }
 
-
 void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled)
 {
     if (!m_node->hasTagName(inputTag))
@@ -141,6 +141,22 @@ void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled)
     static_cast<HTMLInputElement*>(m_node.get())->setAutofilled(filled);
 }
 
+bool InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit()
+{
+    if (!m_node->hasTagName(inputTag))
+        return false;
+
+    return static_cast<HTMLInputElement*>(m_node.get())->lastChangeWasUserEdit();
+}
+
+bool InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit()
+{
+    if (!m_node->hasTagName(textareaTag))
+        return false;
+
+    return static_cast<HTMLTextAreaElement*>(m_node.get())->lastChangeWasUserEdit();
+}
+
 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove()
 {
     if (!m_node->hasTagName(tdTag))
index 0dcebf6..e4a5ab9 100644 (file)
@@ -63,6 +63,9 @@ public:
     void setHTMLInputElementValueForUser(const String&);
     bool isHTMLInputElementAutofilled() const;
     void setHTMLInputElementAutofilled(bool);
+    bool htmlInputElementLastChangeWasUserEdit();
+    bool htmlTextAreaElementLastChangeWasUserEdit();
+    
     PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove();
 
     PassRefPtr<WebFrame> documentFrame();