Commit 960ab441 authored by weinig@apple.com's avatar weinig@apple.com

Add WebKit2 API to figure out if an input or textarea was edited

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: svn://svn.chromium.org/blink/trunk@81263 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 40c8716a
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> 2011-03-15 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky. Reviewed by Yury Semikhatsky.
......
...@@ -1115,6 +1115,7 @@ __ZNK7WebCore15VisiblePosition4nextENS_27EditingBoundaryCrossingRuleE ...@@ -1115,6 +1115,7 @@ __ZNK7WebCore15VisiblePosition4nextENS_27EditingBoundaryCrossingRuleE
__ZNK7WebCore15VisiblePosition8previousENS_27EditingBoundaryCrossingRuleE __ZNK7WebCore15VisiblePosition8previousENS_27EditingBoundaryCrossingRuleE
__ZNK7WebCore16FontFallbackList10fontDataAtEPKNS_4FontEj __ZNK7WebCore16FontFallbackList10fontDataAtEPKNS_4FontEj
__ZNK7WebCore16HTMLInputElement12autoCompleteEv __ZNK7WebCore16HTMLInputElement12autoCompleteEv
__ZNK7WebCore16HTMLInputElement21lastChangeWasUserEditEv
__ZNK7WebCore16IconDatabaseBase12databasePathEv __ZNK7WebCore16IconDatabaseBase12databasePathEv
__ZNK7WebCore16ResourceResponse13nsURLResponseEv __ZNK7WebCore16ResourceResponse13nsURLResponseEv
__ZNK7WebCore16VisibleSelection17isContentEditableEv __ZNK7WebCore16VisibleSelection17isContentEditableEv
...@@ -1124,6 +1125,7 @@ __ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv ...@@ -1124,6 +1125,7 @@ __ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv
__ZNK7WebCore16VisibleSelection5isAllENS_27EditingBoundaryCrossingRuleE __ZNK7WebCore16VisibleSelection5isAllENS_27EditingBoundaryCrossingRuleE
__ZNK7WebCore17ResourceErrorBase8lazyInitEv __ZNK7WebCore17ResourceErrorBase8lazyInitEv
__ZNK7WebCore19AnimationController24numberOfActiveAnimationsEv __ZNK7WebCore19AnimationController24numberOfActiveAnimationsEv
__ZNK7WebCore19HTMLTextAreaElement21lastChangeWasUserEditEv
__ZNK7WebCore19ResourceRequestBase10httpMethodEv __ZNK7WebCore19ResourceRequestBase10httpMethodEv
__ZNK7WebCore19ResourceRequestBase15httpHeaderFieldEPKc __ZNK7WebCore19ResourceRequestBase15httpHeaderFieldEPKc
__ZNK7WebCore19ResourceRequestBase3urlEv __ZNK7WebCore19ResourceRequestBase3urlEv
......
...@@ -182,8 +182,7 @@ ...@@ -182,8 +182,7 @@
- (BOOL)_isEdited - (BOOL)_isEdited
{ {
WebCore::RenderObject *renderer = core(self)->renderer(); return core(self)->lastChangeWasUserEdit();
return renderer && [self _isTextField] && static_cast<WebCore::RenderTextControl *>(renderer)->lastChangeWasUserEdit();
} }
@end @end
...@@ -192,8 +191,7 @@ ...@@ -192,8 +191,7 @@
- (BOOL)_isEdited - (BOOL)_isEdited
{ {
WebCore::RenderObject* renderer = core(self)->renderer(); return core(self)->lastChangeWasUserEdit();
return renderer && static_cast<WebCore::RenderTextControl*>(renderer)->lastChangeWasUserEdit();
} }
@end @end
......
...@@ -146,6 +146,17 @@ void HTMLInputElement::updateCheckedRadioButtons() ...@@ -146,6 +146,17 @@ void HTMLInputElement::updateCheckedRadioButtons()
renderer()->theme()->stateChanged(renderer(), CheckedState); 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 bool HTMLInputElement::isValidValue(const String& value) const
{ {
if (!m_inputType->canSetStringValue()) { if (!m_inputType->canSetStringValue()) {
......
...@@ -199,6 +199,8 @@ public: ...@@ -199,6 +199,8 @@ public:
void handleBeforeTextInsertedEvent(Event*); void handleBeforeTextInsertedEvent(Event*);
void updateCheckedRadioButtons(); void updateCheckedRadioButtons();
bool lastChangeWasUserEdit() const;
protected: protected:
HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser); HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
......
...@@ -421,6 +421,13 @@ void HTMLTextAreaElement::setRows(int rows) ...@@ -421,6 +421,13 @@ void HTMLTextAreaElement::setRows(int rows)
setAttribute(rowsAttr, String::number(rows)); setAttribute(rowsAttr, String::number(rows));
} }
bool HTMLTextAreaElement::lastChangeWasUserEdit() const
{
if (!renderer())
return false;
return toRenderTextControl(renderer())->lastChangeWasUserEdit();
}
bool HTMLTextAreaElement::shouldUseInputMethod() const bool HTMLTextAreaElement::shouldUseInputMethod() const
{ {
return true; return true;
......
...@@ -55,7 +55,9 @@ public: ...@@ -55,7 +55,9 @@ public:
void setCols(int); void setCols(int);
void setRows(int); void setRows(int);
bool lastChangeWasUserEdit() const;
void cacheSelection(int s, int e) { m_cachedSelectionStart = s; m_cachedSelectionEnd = e; }; void cacheSelection(int s, int e) { m_cachedSelectionStart = s; m_cachedSelectionEnd = e; };
private: private:
......
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> 2011-03-16 Brady Eidson <beidson@apple.com>
Reviewed by Adam Roben. Reviewed by Adam Roben.
......
...@@ -76,6 +76,16 @@ void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlI ...@@ -76,6 +76,16 @@ void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlI
toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled); toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled);
} }
bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandleRef)
{
return toImpl(htmlInputElementHandleRef)->htmlInputElementLastChangeWasUserEdit();
}
bool WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlTextAreaElementHandleRef)
{
return toImpl(htmlTextAreaElementHandleRef)->htmlTextAreaElementLastChangeWasUserEdit();
}
WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandleRef) WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandleRef)
{ {
RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(htmlTableCellElementHandleRef)->htmlTableCellElementCellAbove(); RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(htmlTableCellElementHandleRef)->htmlTableCellElementCellAbove();
......
...@@ -50,7 +50,11 @@ WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandl ...@@ -50,7 +50,11 @@ WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandl
WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value);
WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle);
WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); 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 */ /* HTMLTableCellElement Specific Operations */
WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandle); WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandle);
......
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
#include "WebFrameLoaderClient.h" #include "WebFrameLoaderClient.h"
#include <JavaScriptCore/APICast.h> #include <JavaScriptCore/APICast.h>
#include <WebCore/Document.h> #include <WebCore/Document.h>
#include <WebCore/Frame.h>
#include <WebCore/HTMLFrameElement.h> #include <WebCore/HTMLFrameElement.h>
#include <WebCore/HTMLIFrameElement.h> #include <WebCore/HTMLIFrameElement.h>
#include <WebCore/Frame.h>
#include <WebCore/HTMLInputElement.h> #include <WebCore/HTMLInputElement.h>
#include <WebCore/HTMLNames.h> #include <WebCore/HTMLNames.h>
#include <WebCore/HTMLTableCellElement.h> #include <WebCore/HTMLTableCellElement.h>
#include <WebCore/HTMLTextAreaElement.h>
#include <WebCore/IntRect.h> #include <WebCore/IntRect.h>
#include <WebCore/JSNode.h> #include <WebCore/JSNode.h>
#include <WebCore/Node.h> #include <WebCore/Node.h>
...@@ -132,7 +133,6 @@ bool InjectedBundleNodeHandle::isHTMLInputElementAutofilled() const ...@@ -132,7 +133,6 @@ bool InjectedBundleNodeHandle::isHTMLInputElementAutofilled() const
return static_cast<HTMLInputElement*>(m_node.get())->isAutofilled(); return static_cast<HTMLInputElement*>(m_node.get())->isAutofilled();
} }
void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled) void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled)
{ {
if (!m_node->hasTagName(inputTag)) if (!m_node->hasTagName(inputTag))
...@@ -141,6 +141,22 @@ void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled) ...@@ -141,6 +141,22 @@ void InjectedBundleNodeHandle::setHTMLInputElementAutofilled(bool filled)
static_cast<HTMLInputElement*>(m_node.get())->setAutofilled(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() PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove()
{ {
if (!m_node->hasTagName(tdTag)) if (!m_node->hasTagName(tdTag))
......
...@@ -63,6 +63,9 @@ public: ...@@ -63,6 +63,9 @@ public:
void setHTMLInputElementValueForUser(const String&); void setHTMLInputElementValueForUser(const String&);
bool isHTMLInputElementAutofilled() const; bool isHTMLInputElementAutofilled() const;
void setHTMLInputElementAutofilled(bool); void setHTMLInputElementAutofilled(bool);
bool htmlInputElementLastChangeWasUserEdit();
bool htmlTextAreaElementLastChangeWasUserEdit();
PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove(); PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove();
PassRefPtr<WebFrame> documentFrame(); PassRefPtr<WebFrame> documentFrame();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment