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>
Reviewed by Yury Semikhatsky.
......
......@@ -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
......
......@@ -182,8 +182,7 @@
- (BOOL)_isEdited
{
WebCore::RenderObject *renderer = core(self)->renderer();
return renderer && [self _isTextField] && static_cast<WebCore::RenderTextControl *>(renderer)->lastChangeWasUserEdit();
return core(self)->lastChangeWasUserEdit();
}
@end
......@@ -192,8 +191,7 @@
- (BOOL)_isEdited
{
WebCore::RenderObject* renderer = core(self)->renderer();
return renderer && static_cast<WebCore::RenderTextControl*>(renderer)->lastChangeWasUserEdit();
return core(self)->lastChangeWasUserEdit();
}
@end
......
......@@ -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()) {
......
......@@ -199,6 +199,8 @@ public:
void handleBeforeTextInsertedEvent(Event*);
void updateCheckedRadioButtons();
bool lastChangeWasUserEdit() const;
protected:
HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
......
......@@ -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;
......
......@@ -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:
......
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.
......
......@@ -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();
......
......@@ -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);
......
......@@ -30,12 +30,13 @@
#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))
......
......@@ -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();
......
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