[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e
darin at apple.com
darin at apple.com
Fri Jan 21 14:49:57 UTC 2011
The following commit has been merged in the debian/experimental branch:
commit 7e8868d320d2212d20b8659d6538796413ce9659
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jan 1 00:58:22 2011 +0000
2010-12-31 Darin Adler <darin at apple.com>
Reviewed by Dan Bernstein.
Some renaming and refactoring of form element code
https://bugs.webkit.org/show_bug.cgi?id=51784
* bindings/js/JSHTMLSelectElementCustom.cpp:
(WebCore::JSHTMLSelectElement::remove): Call new overload of remove
for option elements instead of putting the logic in the binding.
* html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::HTMLButtonElement): Updated for name changes.
(WebCore::HTMLButtonElement::defaultEventHandler): Renamed argument to
"event" instead of "evt". Also updated for name changes.
(WebCore::HTMLButtonElement::isActivatedSubmit): Ditto.
(WebCore::HTMLButtonElement::setActivatedSubmit): Ditto.
(WebCore::HTMLButtonElement::appendFormData): Ditto.
* html/HTMLButtonElement.h: Renamed m_activeSubmit to m_isActivatedSubmit
to match the getter function name. The name still doesn't seem great.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::HTMLFormElement): Updated for name changes.
(WebCore::HTMLFormElement::~HTMLFormElement): Use autoComplete function
instead of m_autocomplete data member.
(WebCore::HTMLFormElement::rendererIsNeeded): Use m_wasDemoted data member
instead of otherwise-unused isDemoted function.
(WebCore::HTMLFormElement::submitImplicitly): Updated for name changes.
(WebCore::HTMLFormElement::validateInteractively): Removed code to clear
m_insubmit. This is now handled by the caller, prepareForSubmission.
(WebCore::HTMLFormElement::prepareForSubmission): Renamed. Updated for
name changes. Moved code to clear m_isSubmittingOrPreparingForSubmission
here from validateInteractively. Removed unneeded check of m_doingsubmit
boolean before setting it.
(WebCore::HTMLFormElement::submit): Factored this function into two.
One for JavaScript and one for non-JavaScript. Neither function needs a frame
argument, because the question being asked, anyPageIsProcessingUserGesture,
is a question asked of an entire page group, not a specific frame or page,
so it's not important which is the active frame.
(WebCore::HTMLFormElement::submitFromJavaScript): Ditto.
(WebCore::HTMLFormElement::reset): Updated for name changes.
(WebCore::HTMLFormElement::parseMappedAttribute): Removed code to parse
acceptAttr and got rid of code to set m_autocomplete.
(WebCore::HTMLFormElement::elementForAlias): Changed return type to a raw
pointer.
(WebCore::HTMLFormElement::getNamedElements): Updated to use raw pointer
and the vector find function. Added a FIXME about the comment.
(WebCore::HTMLFormElement::documentDidBecomeActive): Use autoComplete
function instead of m_autocomplete data member.
(WebCore::HTMLFormElement::willMoveToNewOwnerDocument): Ditto.
(WebCore::HTMLFormElement::didMoveToNewOwnerDocument): Ditto.
(WebCore::HTMLFormElement::autoComplete): Ditto.
* html/HTMLFormElement.h: Added a FIXME about renaming the autoComplete
function. Renamed prepareSubmit to prepareForSubmission. Got rid of the
frame argument from the submit function and added a new submitFromJavaScript
variant. Removed the unneeded isDemoted function. Changed the return type
of elementForAlias to a raw pointer. Removed m_autocomplete. Renamed
m_insubmit to m_isSubmittingOrPreparingForSubmission, m_doingsubmit to
m_shouldSubmit, m_inreset to m_inResetFunction, m_malformed to m_wasMalformed,
m_demoted to m_wasDemoted. Use plain bool instead of bitfields.
* html/HTMLFormElement.idl: Use the function named submitFromJavaScript
instead of using CallWith=DynamicFrame because we don't need to know
what frame is calling. If we did, it's not clear that the "dynamic"
frame would be the right one anyway.
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::remove): Added an overload that takes an option
element, since the JavaScript binding supports this.
* html/HTMLSelectElement.h: Ditto.
* html/ImageInputType.cpp:
(WebCore::ImageInputType::handleDOMActivateEvent): Updated for name changes.
* html/ImageInputType.h: Ditto.
* html/SubmitInputType.cpp:
(WebCore::SubmitInputType::handleDOMActivateEvent): Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74841 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1ab9473..ca98498 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,80 @@
+2010-12-31 Darin Adler <darin at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Some renaming and refactoring of form element code
+ https://bugs.webkit.org/show_bug.cgi?id=51784
+
+ * bindings/js/JSHTMLSelectElementCustom.cpp:
+ (WebCore::JSHTMLSelectElement::remove): Call new overload of remove
+ for option elements instead of putting the logic in the binding.
+
+ * html/HTMLButtonElement.cpp:
+ (WebCore::HTMLButtonElement::HTMLButtonElement): Updated for name changes.
+ (WebCore::HTMLButtonElement::defaultEventHandler): Renamed argument to
+ "event" instead of "evt". Also updated for name changes.
+ (WebCore::HTMLButtonElement::isActivatedSubmit): Ditto.
+ (WebCore::HTMLButtonElement::setActivatedSubmit): Ditto.
+ (WebCore::HTMLButtonElement::appendFormData): Ditto.
+ * html/HTMLButtonElement.h: Renamed m_activeSubmit to m_isActivatedSubmit
+ to match the getter function name. The name still doesn't seem great.
+
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::HTMLFormElement): Updated for name changes.
+ (WebCore::HTMLFormElement::~HTMLFormElement): Use autoComplete function
+ instead of m_autocomplete data member.
+ (WebCore::HTMLFormElement::rendererIsNeeded): Use m_wasDemoted data member
+ instead of otherwise-unused isDemoted function.
+ (WebCore::HTMLFormElement::submitImplicitly): Updated for name changes.
+ (WebCore::HTMLFormElement::validateInteractively): Removed code to clear
+ m_insubmit. This is now handled by the caller, prepareForSubmission.
+ (WebCore::HTMLFormElement::prepareForSubmission): Renamed. Updated for
+ name changes. Moved code to clear m_isSubmittingOrPreparingForSubmission
+ here from validateInteractively. Removed unneeded check of m_doingsubmit
+ boolean before setting it.
+ (WebCore::HTMLFormElement::submit): Factored this function into two.
+ One for JavaScript and one for non-JavaScript. Neither function needs a frame
+ argument, because the question being asked, anyPageIsProcessingUserGesture,
+ is a question asked of an entire page group, not a specific frame or page,
+ so it's not important which is the active frame.
+ (WebCore::HTMLFormElement::submitFromJavaScript): Ditto.
+ (WebCore::HTMLFormElement::reset): Updated for name changes.
+ (WebCore::HTMLFormElement::parseMappedAttribute): Removed code to parse
+ acceptAttr and got rid of code to set m_autocomplete.
+ (WebCore::HTMLFormElement::elementForAlias): Changed return type to a raw
+ pointer.
+ (WebCore::HTMLFormElement::getNamedElements): Updated to use raw pointer
+ and the vector find function. Added a FIXME about the comment.
+ (WebCore::HTMLFormElement::documentDidBecomeActive): Use autoComplete
+ function instead of m_autocomplete data member.
+ (WebCore::HTMLFormElement::willMoveToNewOwnerDocument): Ditto.
+ (WebCore::HTMLFormElement::didMoveToNewOwnerDocument): Ditto.
+ (WebCore::HTMLFormElement::autoComplete): Ditto.
+ * html/HTMLFormElement.h: Added a FIXME about renaming the autoComplete
+ function. Renamed prepareSubmit to prepareForSubmission. Got rid of the
+ frame argument from the submit function and added a new submitFromJavaScript
+ variant. Removed the unneeded isDemoted function. Changed the return type
+ of elementForAlias to a raw pointer. Removed m_autocomplete. Renamed
+ m_insubmit to m_isSubmittingOrPreparingForSubmission, m_doingsubmit to
+ m_shouldSubmit, m_inreset to m_inResetFunction, m_malformed to m_wasMalformed,
+ m_demoted to m_wasDemoted. Use plain bool instead of bitfields.
+
+ * html/HTMLFormElement.idl: Use the function named submitFromJavaScript
+ instead of using CallWith=DynamicFrame because we don't need to know
+ what frame is calling. If we did, it's not clear that the "dynamic"
+ frame would be the right one anyway.
+
+ * html/HTMLSelectElement.cpp:
+ (WebCore::HTMLSelectElement::remove): Added an overload that takes an option
+ element, since the JavaScript binding supports this.
+ * html/HTMLSelectElement.h: Ditto.
+
+ * html/ImageInputType.cpp:
+ (WebCore::ImageInputType::handleDOMActivateEvent): Updated for name changes.
+ * html/ImageInputType.h: Ditto.
+ * html/SubmitInputType.cpp:
+ (WebCore::SubmitInputType::handleDOMActivateEvent): Ditto.
+
2010-12-31 Daniel Bates <dbates at rim.com>
Reviewed by Darin Adler.
diff --git a/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp b/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
index 5c462c1..2495c1e 100644
--- a/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
+++ b/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Apple, Inc.
+ * Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alexey Proskuryakov (ap at webkit.org)
*
* This library is free software; you can redistribute it and/or
@@ -36,10 +36,9 @@ JSValue JSHTMLSelectElement::remove(ExecState* exec)
{
HTMLSelectElement& select = *static_cast<HTMLSelectElement*>(impl());
- // we support both options index and options objects
- HTMLElement* element = toHTMLElement(exec->argument(0));
- if (element && element->hasTagName(optionTag))
- select.remove(static_cast<HTMLOptionElement*>(element)->index());
+ // The remove function can take either an option object or the index of an option.
+ if (HTMLOptionElement* option = toHTMLOptionElement(exec->argument(0)))
+ select.remove(option);
else
select.remove(exec->argument(0).toInt32(exec));
diff --git a/WebCore/html/HTMLButtonElement.cpp b/WebCore/html/HTMLButtonElement.cpp
index f9cab4c..686790d 100644
--- a/WebCore/html/HTMLButtonElement.cpp
+++ b/WebCore/html/HTMLButtonElement.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll at kde.org)
* (C) 1999 Antti Koivisto (koivisto at kde.org)
* (C) 2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
* (C) 2006 Alexey Proskuryakov (ap at nypop.com)
* Copyright (C) 2007 Samuel Weinig (sam at webkit.org)
*
@@ -43,7 +43,7 @@ using namespace HTMLNames;
inline HTMLButtonElement::HTMLButtonElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
: HTMLFormControlElement(tagName, document, form)
, m_type(SUBMIT)
- , m_activeSubmit(false)
+ , m_isActivatedSubmit(false)
{
ASSERT(hasTagName(buttonTag));
}
@@ -96,47 +96,45 @@ void HTMLButtonElement::parseMappedAttribute(Attribute* attr)
HTMLFormControlElement::parseMappedAttribute(attr);
}
-void HTMLButtonElement::defaultEventHandler(Event* evt)
+void HTMLButtonElement::defaultEventHandler(Event* event)
{
- if (evt->type() == eventNames().DOMActivateEvent && !disabled()) {
+ if (event->type() == eventNames().DOMActivateEvent && !disabled()) {
if (form() && m_type == SUBMIT) {
- m_activeSubmit = true;
- form()->prepareSubmit(evt);
- m_activeSubmit = false; // in case we were canceled
+ m_isActivatedSubmit = true;
+ form()->prepareForSubmission(event);
+ m_isActivatedSubmit = false; // Do this in case submission was canceled.
}
if (form() && m_type == RESET)
form()->reset();
}
- if (evt->isKeyboardEvent()) {
- if (evt->type() == eventNames().keydownEvent && static_cast<KeyboardEvent*>(evt)->keyIdentifier() == "U+0020") {
+ if (event->isKeyboardEvent()) {
+ if (event->type() == eventNames().keydownEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
setActive(true, true);
// No setDefaultHandled() - IE dispatches a keypress in this case.
return;
}
- if (evt->type() == eventNames().keypressEvent) {
- switch (static_cast<KeyboardEvent*>(evt)->charCode()) {
+ if (event->type() == eventNames().keypressEvent) {
+ switch (static_cast<KeyboardEvent*>(event)->charCode()) {
case '\r':
- dispatchSimulatedClick(evt);
- evt->setDefaultHandled();
+ dispatchSimulatedClick(event);
+ event->setDefaultHandled();
return;
case ' ':
// Prevent scrolling down the page.
- evt->setDefaultHandled();
+ event->setDefaultHandled();
return;
- default:
- break;
}
}
- if (evt->type() == eventNames().keyupEvent && static_cast<KeyboardEvent*>(evt)->keyIdentifier() == "U+0020") {
+ if (event->type() == eventNames().keyupEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
if (active())
- dispatchSimulatedClick(evt);
- evt->setDefaultHandled();
+ dispatchSimulatedClick(event);
+ event->setDefaultHandled();
return;
}
}
- HTMLFormControlElement::defaultEventHandler(evt);
+ HTMLFormControlElement::defaultEventHandler(event);
}
bool HTMLButtonElement::isSuccessfulSubmitButton() const
@@ -148,17 +146,17 @@ bool HTMLButtonElement::isSuccessfulSubmitButton() const
bool HTMLButtonElement::isActivatedSubmit() const
{
- return m_activeSubmit;
+ return m_isActivatedSubmit;
}
void HTMLButtonElement::setActivatedSubmit(bool flag)
{
- m_activeSubmit = flag;
+ m_isActivatedSubmit = flag;
}
bool HTMLButtonElement::appendFormData(FormDataList& formData, bool)
{
- if (m_type != SUBMIT || name().isEmpty() || !m_activeSubmit)
+ if (m_type != SUBMIT || name().isEmpty() || !m_isActivatedSubmit)
return false;
formData.appendData(name(), value());
return true;
diff --git a/WebCore/html/HTMLButtonElement.h b/WebCore/html/HTMLButtonElement.h
index 2ed5136..0d64f06 100644
--- a/WebCore/html/HTMLButtonElement.h
+++ b/WebCore/html/HTMLButtonElement.h
@@ -62,7 +62,7 @@ private:
virtual bool recalcWillValidate() const;
Type m_type;
- bool m_activeSubmit;
+ bool m_isActivatedSubmit;
};
} // namespace
diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp
index 52669b5..c896bbf 100644
--- a/WebCore/html/HTMLFormElement.cpp
+++ b/WebCore/html/HTMLFormElement.cpp
@@ -68,12 +68,11 @@ HTMLFormElement::HTMLFormElement(const QualifiedName& tagName, Document* documen
, m_associatedElementsBeforeIndex(0)
, m_associatedElementsAfterIndex(0)
, m_wasUserSubmitted(false)
- , m_autocomplete(true)
- , m_insubmit(false)
- , m_doingsubmit(false)
- , m_inreset(false)
- , m_malformed(false)
- , m_demoted(false)
+ , m_isSubmittingOrPreparingForSubmission(false)
+ , m_shouldSubmit(false)
+ , m_isInResetFunction(false)
+ , m_wasMalformed(false)
+ , m_wasDemoted(false)
{
ASSERT(hasTagName(formTag));
}
@@ -90,7 +89,7 @@ PassRefPtr<HTMLFormElement> HTMLFormElement::create(const QualifiedName& tagName
HTMLFormElement::~HTMLFormElement()
{
- if (!m_autocomplete)
+ if (!autoComplete())
document()->unregisterForDocumentActivationCallbacks(this);
for (unsigned i = 0; i < m_associatedElements.size(); ++i)
@@ -106,7 +105,7 @@ bool HTMLFormElement::formWouldHaveSecureSubmission(const String& url)
bool HTMLFormElement::rendererIsNeeded(RenderStyle* style)
{
- if (!isDemoted())
+ if (!m_wasDemoted)
return HTMLElement::rendererIsNeeded(style);
ContainerNode* node = parentNode();
@@ -192,7 +191,7 @@ void HTMLFormElement::submitImplicitly(Event* event, bool fromImplicitSubmission
++submissionTriggerCount;
}
if (fromImplicitSubmissionTrigger && submissionTriggerCount == 1)
- prepareSubmit(event);
+ prepareForSubmission(event);
}
static inline HTMLFormControlElement* submitElementFromEvent(const Event* event)
@@ -258,42 +257,48 @@ bool HTMLFormElement::validateInteractively(Event* event)
frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, ErrorMessageLevel, message, 0, document()->url().string());
}
}
- m_insubmit = false;
return false;
}
-bool HTMLFormElement::prepareSubmit(Event* event)
+bool HTMLFormElement::prepareForSubmission(Event* event)
{
Frame* frame = document()->frame();
- if (m_insubmit || !frame)
- return m_insubmit;
+ if (m_isSubmittingOrPreparingForSubmission || !frame)
+ return m_isSubmittingOrPreparingForSubmission;
- m_insubmit = true;
- m_doingsubmit = false;
+ m_isSubmittingOrPreparingForSubmission = true;
+ m_shouldSubmit = false;
// Interactive validation must be done before dispatching the submit event.
- if (!validateInteractively(event))
+ if (!validateInteractively(event)) {
+ m_isSubmittingOrPreparingForSubmission = false;
return false;
+ }
frame->loader()->client()->dispatchWillSendSubmitEvent(this);
- if (dispatchEvent(Event::create(eventNames().submitEvent, true, true)) && !m_doingsubmit)
- m_doingsubmit = true;
+ if (dispatchEvent(Event::create(eventNames().submitEvent, true, true)))
+ m_shouldSubmit = true;
- m_insubmit = false;
+ m_isSubmittingOrPreparingForSubmission = false;
- if (m_doingsubmit)
+ if (m_shouldSubmit)
submit(event, true, true, NotSubmittedByJavaScript);
- return m_doingsubmit;
+ return m_shouldSubmit;
+}
+
+void HTMLFormElement::submit()
+{
+ submit(0, false, true, NotSubmittedByJavaScript);
}
-void HTMLFormElement::submit(Frame* javaScriptActiveFrame)
+void HTMLFormElement::submitFromJavaScript()
{
- if (javaScriptActiveFrame)
- submit(0, false, javaScriptActiveFrame->script()->anyPageIsProcessingUserGesture(), SubmittedByJavaScript);
- else
- submit(0, false, true, NotSubmittedByJavaScript);
+ Frame* frame = document()->frame();
+ if (!frame)
+ return;
+ submit(0, false, frame->script()->anyPageIsProcessingUserGesture(), SubmittedByJavaScript);
}
void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger formSubmissionTrigger)
@@ -303,12 +308,12 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce
if (!view || !frame)
return;
- if (m_insubmit) {
- m_doingsubmit = true;
+ if (m_isSubmittingOrPreparingForSubmission) {
+ m_shouldSubmit = true;
return;
}
- m_insubmit = true;
+ m_isSubmittingOrPreparingForSubmission = true;
m_wasUserSubmitted = processingUserGesture;
HTMLFormControlElement* firstSuccessfulSubmitButton = 0;
@@ -335,21 +340,20 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce
if (needButtonActivation && firstSuccessfulSubmitButton)
firstSuccessfulSubmitButton->setActivatedSubmit(false);
- m_doingsubmit = m_insubmit = false;
+ m_shouldSubmit = false;
+ m_isSubmittingOrPreparingForSubmission = false;
}
void HTMLFormElement::reset()
{
Frame* frame = document()->frame();
- if (m_inreset || !frame)
+ if (m_isInResetFunction || !frame)
return;
- m_inreset = true;
+ m_isInResetFunction = true;
- // ### DOM2 labels this event as not cancelable, however
- // common browsers( sick! ) allow it be cancelled.
if (!dispatchEvent(Event::create(eventNames().resetEvent, true, true))) {
- m_inreset = false;
+ m_isInResetFunction = false;
return;
}
@@ -358,7 +362,7 @@ void HTMLFormElement::reset()
static_cast<HTMLFormControlElement*>(m_associatedElements[i])->reset();
}
- m_inreset = false;
+ m_isInResetFunction = false;
}
void HTMLFormElement::parseMappedAttribute(Attribute* attr)
@@ -372,14 +376,9 @@ void HTMLFormElement::parseMappedAttribute(Attribute* attr)
else if (attr->name() == enctypeAttr)
m_attributes.parseEncodingType(attr->value());
else if (attr->name() == accept_charsetAttr)
- // space separated list of charsets the server
- // accepts - see rfc2045
m_attributes.setAcceptCharset(attr->value());
- else if (attr->name() == acceptAttr) {
- // ignore this one for the moment...
- } else if (attr->name() == autocompleteAttr) {
- m_autocomplete = !equalIgnoringCase(attr->value(), "off");
- if (!m_autocomplete)
+ else if (attr->name() == autocompleteAttr) {
+ if (!autoComplete())
document()->registerForDocumentActivationCallbacks(this);
else
document()->unregisterForDocumentActivationCallbacks(this);
@@ -606,11 +605,11 @@ void HTMLFormElement::collectUnhandledInvalidControls(Vector<RefPtr<FormAssociat
}
}
-PassRefPtr<HTMLFormControlElement> HTMLFormElement::elementForAlias(const AtomicString& alias)
+HTMLFormControlElement* HTMLFormElement::elementForAlias(const AtomicString& alias)
{
if (alias.isEmpty() || !m_elementAliases)
return 0;
- return m_elementAliases->get(alias.impl());
+ return m_elementAliases->get(alias.impl()).get();
}
void HTMLFormElement::addElementAlias(HTMLFormControlElement* element, const AtomicString& alias)
@@ -626,28 +625,21 @@ void HTMLFormElement::getNamedElements(const AtomicString& name, Vector<RefPtr<N
{
elements()->namedItems(name, namedItems);
- // see if we have seen something with this name before
- RefPtr<HTMLFormControlElement> aliasElem;
- if ((aliasElem = elementForAlias(name))) {
- bool found = false;
- for (unsigned n = 0; n < namedItems.size(); n++) {
- if (namedItems[n] == aliasElem.get()) {
- found = true;
- break;
- }
+ HTMLFormControlElement* aliasElement = elementForAlias(name);
+ if (aliasElement) {
+ if (namedItems.find(aliasElement) == notFound) {
+ // We have seen it before but it is gone now. Still, we need to return it.
+ // FIXME: The above comment is not clear enough; it does not say why we need to do this.
+ namedItems.append(aliasElement);
}
- if (!found)
- // we have seen it before but it is gone now. still, we need to return it.
- namedItems.append(aliasElem.get());
}
- // name has been accessed, remember it
- if (namedItems.size() && aliasElem != namedItems.first())
+ if (namedItems.size() && namedItems.first() != aliasElement)
addElementAlias(static_cast<HTMLFormControlElement*>(namedItems.first().get()), name);
}
void HTMLFormElement::documentDidBecomeActive()
{
- ASSERT(!m_autocomplete);
+ ASSERT(!autoComplete());
for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
if (m_associatedElements[i]->isFormControlElement())
@@ -657,16 +649,21 @@ void HTMLFormElement::documentDidBecomeActive()
void HTMLFormElement::willMoveToNewOwnerDocument()
{
- if (!m_autocomplete)
+ if (!autoComplete())
document()->unregisterForDocumentActivationCallbacks(this);
HTMLElement::willMoveToNewOwnerDocument();
}
void HTMLFormElement::didMoveToNewOwnerDocument()
{
- if (!m_autocomplete)
+ if (!autoComplete())
document()->registerForDocumentActivationCallbacks(this);
HTMLElement::didMoveToNewOwnerDocument();
}
+bool HTMLFormElement::autoComplete() const
+{
+ return !equalIgnoringCase(fastGetAttribute(autocompleteAttr), "off");
+}
+
} // namespace
diff --git a/WebCore/html/HTMLFormElement.h b/WebCore/html/HTMLFormElement.h
index e18b524..bd087b8 100644
--- a/WebCore/html/HTMLFormElement.h
+++ b/WebCore/html/HTMLFormElement.h
@@ -61,25 +61,27 @@ public:
String encoding() const { return m_attributes.encodingType(); }
void setEncoding(const String& value) { setEnctype(value); }
- bool autoComplete() const { return m_autocomplete; }
+ // FIXME: Rename this function to shouldAutocomplete.
+ bool autoComplete() const;
- // FIXME: Should rename these two functions to say "form control"
- // or "form-associated element" instead of "form element".
+ // FIXME: Should rename these two functions to say "form control" or "form-associated element" instead of "form element".
void registerFormElement(FormAssociatedElement*);
void removeFormElement(FormAssociatedElement*);
+
void registerImgElement(HTMLImageElement*);
void removeImgElement(HTMLImageElement*);
- bool prepareSubmit(Event*);
- void submit(Frame* javaScriptActiveFrame = 0);
+ bool prepareForSubmission(Event*);
+ void submit();
+ void submitFromJavaScript();
void reset();
// Used to indicate a malformed state to keep from applying the bottom margin of the form.
- void setMalformed(bool malformed) { m_malformed = malformed; }
- bool isMalformed() const { return m_malformed; }
+ // FIXME: Would probably be better to call this wasUnclosed; that's more specific.
+ void setMalformed(bool malformed) { m_wasMalformed = malformed; }
+ bool isMalformed() const { return m_wasMalformed; }
- void setDemoted(bool demoted) { m_demoted = demoted; }
- bool isDemoted() const { return m_demoted; }
+ void setDemoted(bool demoted) { m_wasDemoted = demoted; }
void submitImplicitly(Event*, bool fromImplicitSubmissionTrigger);
bool formWouldHaveSecureSubmission(const String& url);
@@ -105,7 +107,7 @@ public:
bool checkValidity();
- PassRefPtr<HTMLFormControlElement> elementForAlias(const AtomicString&);
+ HTMLFormControlElement* elementForAlias(const AtomicString&);
void addElementAlias(HTMLFormControlElement*, const AtomicString& alias);
CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
@@ -134,8 +136,10 @@ private:
unsigned formElementIndexWithFormAttribute(Element*);
unsigned formElementIndex(FormAssociatedElement*);
- // Returns true if the submission should be proceeded.
+
+ // Returns true if the submission should proceed.
bool validateInteractively(Event*);
+
// Validates each of the controls, and stores controls of which 'invalid'
// event was not canceled to the specified vector.
void collectUnhandledInvalidControls(Vector<RefPtr<FormAssociatedElement> >&);
@@ -156,13 +160,14 @@ private:
Vector<HTMLImageElement*> m_imageElements;
bool m_wasUserSubmitted;
+ bool m_isSubmittingOrPreparingForSubmission;
+ bool m_shouldSubmit;
+
+ bool m_isInResetFunction;
+
+ bool m_wasMalformed;
+ bool m_wasDemoted;
- bool m_autocomplete : 1;
- bool m_insubmit : 1;
- bool m_doingsubmit : 1;
- bool m_inreset : 1;
- bool m_malformed : 1;
- bool m_demoted : 1;
AtomicString m_name;
};
diff --git a/WebCore/html/HTMLFormElement.idl b/WebCore/html/HTMLFormElement.idl
index a9f8ea1..e9759e2 100644
--- a/WebCore/html/HTMLFormElement.idl
+++ b/WebCore/html/HTMLFormElement.idl
@@ -31,13 +31,18 @@ module html {
attribute [Reflect] boolean noValidate;
attribute [Reflect=accept_charset] DOMString acceptCharset;
attribute [Reflect, URL] DOMString action;
- attribute [ConvertNullToNullString] DOMString encoding; /* Netscape/Firefox legacy attribute. Same as enctype. */
+ attribute [ConvertNullToNullString] DOMString encoding;
attribute [ConvertNullToNullString] DOMString enctype;
attribute [Reflect] DOMString method;
attribute [Reflect] DOMString target;
- [CallWith=DynamicFrame] void submit();
+#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
+ [ImplementationFunction=submitFromJavaScript] void submit();
+#else
+ void submit();
+#endif
void reset();
boolean checkValidity();
};
+
}
diff --git a/WebCore/html/HTMLSelectElement.cpp b/WebCore/html/HTMLSelectElement.cpp
index 2dc882d..c7f47f2 100644
--- a/WebCore/html/HTMLSelectElement.cpp
+++ b/WebCore/html/HTMLSelectElement.cpp
@@ -176,7 +176,7 @@ unsigned HTMLSelectElement::length() const
return SelectElement::optionCount(m_data, this);
}
-void HTMLSelectElement::add(HTMLElement *element, HTMLElement *before, ExceptionCode& ec)
+void HTMLSelectElement::add(HTMLElement* element, HTMLElement* before, ExceptionCode& ec)
{
RefPtr<HTMLElement> protectNewChild(element); // make sure the element is ref'd and deref'd so we don't leak it
@@ -187,17 +187,23 @@ void HTMLSelectElement::add(HTMLElement *element, HTMLElement *before, Exception
setNeedsValidityCheck();
}
-void HTMLSelectElement::remove(int index)
+void HTMLSelectElement::remove(int optionIndex)
{
- int listIndex = optionToListIndex(index);
+ int listIndex = optionToListIndex(optionIndex);
if (listIndex < 0)
return;
- Element* item = listItems()[listIndex];
- ASSERT(item->parentNode());
ExceptionCode ec;
- item->parentNode()->removeChild(item, ec);
- setNeedsValidityCheck();
+ listItems()[listIndex]->remove(ec);
+}
+
+void HTMLSelectElement::remove(HTMLOptionElement* option)
+{
+ if (option->ownerSelectElement() != this)
+ return;
+
+ ExceptionCode ec;
+ option->remove(ec);
}
String HTMLSelectElement::value()
diff --git a/WebCore/html/HTMLSelectElement.h b/WebCore/html/HTMLSelectElement.h
index 0bfb6a0..a22df02 100644
--- a/WebCore/html/HTMLSelectElement.h
+++ b/WebCore/html/HTMLSelectElement.h
@@ -51,8 +51,9 @@ public:
virtual int size() const { return m_data.size(); }
virtual bool multiple() const { return m_data.multiple(); }
- void add(HTMLElement* element, HTMLElement* before, ExceptionCode&);
+ void add(HTMLElement*, HTMLElement* beforeElement, ExceptionCode&);
void remove(int index);
+ void remove(HTMLOptionElement*);
String value();
void setValue(const String&);
diff --git a/WebCore/html/ImageInputType.cpp b/WebCore/html/ImageInputType.cpp
index 1ff3f49..572caa7 100644
--- a/WebCore/html/ImageInputType.cpp
+++ b/WebCore/html/ImageInputType.cpp
@@ -73,7 +73,7 @@ void ImageInputType::handleDOMActivateEvent(Event* event)
m_clickLocation = IntPoint(mouseEvent->offsetX(), mouseEvent->offsetY());
} else
m_clickLocation = IntPoint();
- element->form()->prepareSubmit(event); // Event handlers can run.
+ element->form()->prepareForSubmission(event); // Event handlers can run.
element->setActivatedSubmit(false);
event->setDefaultHandled();
}
diff --git a/WebCore/html/ImageInputType.h b/WebCore/html/ImageInputType.h
index 7e53622..1fd92f4 100644
--- a/WebCore/html/ImageInputType.h
+++ b/WebCore/html/ImageInputType.h
@@ -49,7 +49,7 @@ private:
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
virtual void handleDOMActivateEvent(Event*);
- // This is valid only during HTMLFormElement::prepareSubmit().
+ // This is valid only during HTMLFormElement::prepareForSubmission().
IntPoint m_clickLocation;
};
diff --git a/WebCore/html/SubmitInputType.cpp b/WebCore/html/SubmitInputType.cpp
index d7b8234..155aa22 100644
--- a/WebCore/html/SubmitInputType.cpp
+++ b/WebCore/html/SubmitInputType.cpp
@@ -67,7 +67,7 @@ void SubmitInputType::handleDOMActivateEvent(Event* event)
if (element->disabled() || !element->form())
return;
element->setActivatedSubmit(true);
- element->form()->prepareSubmit(event); // Event handlers can run.
+ element->form()->prepareForSubmission(event); // Event handlers can run.
element->setActivatedSubmit(false);
event->setDefaultHandled();
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list