OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "core/html/HTMLFormElement.h" | 25 #include "core/html/HTMLFormElement.h" |
26 | 26 |
27 #include "bindings/core/v8/ScriptController.h" | 27 #include "bindings/core/v8/ScriptController.h" |
28 #include "bindings/core/v8/ScriptEventListener.h" | 28 #include "bindings/core/v8/ScriptEventListener.h" |
29 #include "bindings/core/v8/UnionTypesCore.h" | 29 #include "bindings/core/v8/UnionTypesCore.h" |
30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
31 #include "core/dom/Attribute.h" | 31 #include "core/dom/Attribute.h" |
32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
33 #include "core/dom/ElementTraversal.h" | 33 #include "core/dom/ElementTraversal.h" |
34 #include "core/dom/NodeListsNodeData.h" | 34 #include "core/dom/NodeListsNodeData.h" |
35 #include "core/events/AutocompleteErrorEvent.h" | |
36 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
37 #include "core/events/GenericEventQueue.h" | |
38 #include "core/events/ScopedEventQueue.h" | 36 #include "core/events/ScopedEventQueue.h" |
39 #include "core/frame/LocalDOMWindow.h" | 37 #include "core/frame/LocalDOMWindow.h" |
40 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
41 #include "core/frame/UseCounter.h" | 39 #include "core/frame/UseCounter.h" |
42 #include "core/frame/csp/ContentSecurityPolicy.h" | 40 #include "core/frame/csp/ContentSecurityPolicy.h" |
43 #include "core/html/HTMLCollection.h" | 41 #include "core/html/HTMLCollection.h" |
44 #include "core/html/HTMLDialogElement.h" | 42 #include "core/html/HTMLDialogElement.h" |
45 #include "core/html/HTMLFormControlsCollection.h" | 43 #include "core/html/HTMLFormControlsCollection.h" |
46 #include "core/html/HTMLImageElement.h" | 44 #include "core/html/HTMLImageElement.h" |
47 #include "core/html/HTMLInputElement.h" | 45 #include "core/html/HTMLInputElement.h" |
(...skipping 18 matching lines...) Expand all Loading... |
66 : HTMLElement(formTag, document) | 64 : HTMLElement(formTag, document) |
67 , m_associatedElementsAreDirty(false) | 65 , m_associatedElementsAreDirty(false) |
68 , m_imageElementsAreDirty(false) | 66 , m_imageElementsAreDirty(false) |
69 , m_hasElementsAssociatedByParser(false) | 67 , m_hasElementsAssociatedByParser(false) |
70 , m_hasElementsAssociatedByFormAttribute(false) | 68 , m_hasElementsAssociatedByFormAttribute(false) |
71 , m_didFinishParsingChildren(false) | 69 , m_didFinishParsingChildren(false) |
72 , m_isSubmittingOrInUserJSSubmitEvent(false) | 70 , m_isSubmittingOrInUserJSSubmitEvent(false) |
73 , m_shouldSubmit(false) | 71 , m_shouldSubmit(false) |
74 , m_isInResetFunction(false) | 72 , m_isInResetFunction(false) |
75 , m_wasDemoted(false) | 73 , m_wasDemoted(false) |
76 , m_pendingAutocompleteEventsQueue(GenericEventQueue::create(this)) | |
77 { | 74 { |
78 } | 75 } |
79 | 76 |
80 HTMLFormElement* HTMLFormElement::create(Document& document) | 77 HTMLFormElement* HTMLFormElement::create(Document& document) |
81 { | 78 { |
82 UseCounter::count(document, UseCounter::FormElement); | 79 UseCounter::count(document, UseCounter::FormElement); |
83 return new HTMLFormElement(document); | 80 return new HTMLFormElement(document); |
84 } | 81 } |
85 | 82 |
86 HTMLFormElement::~HTMLFormElement() | 83 HTMLFormElement::~HTMLFormElement() |
87 { | 84 { |
88 } | 85 } |
89 | 86 |
90 DEFINE_TRACE(HTMLFormElement) | 87 DEFINE_TRACE(HTMLFormElement) |
91 { | 88 { |
92 visitor->trace(m_pastNamesMap); | 89 visitor->trace(m_pastNamesMap); |
93 visitor->trace(m_radioButtonGroupScope); | 90 visitor->trace(m_radioButtonGroupScope); |
94 visitor->trace(m_associatedElements); | 91 visitor->trace(m_associatedElements); |
95 visitor->trace(m_imageElements); | 92 visitor->trace(m_imageElements); |
96 visitor->trace(m_pendingAutocompleteEventsQueue); | |
97 HTMLElement::trace(visitor); | 93 HTMLElement::trace(visitor); |
98 } | 94 } |
99 | 95 |
100 bool HTMLFormElement::matchesValidityPseudoClasses() const | 96 bool HTMLFormElement::matchesValidityPseudoClasses() const |
101 { | 97 { |
102 return true; | 98 return true; |
103 } | 99 } |
104 | 100 |
105 bool HTMLFormElement::isValidElement() | 101 bool HTMLFormElement::isValidElement() |
106 { | 102 { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 437 |
442 const FormAssociatedElement::List& elements = associatedElements(); | 438 const FormAssociatedElement::List& elements = associatedElements(); |
443 for (unsigned i = 0; i < elements.size(); ++i) { | 439 for (unsigned i = 0; i < elements.size(); ++i) { |
444 if (elements[i]->isFormControlElement()) | 440 if (elements[i]->isFormControlElement()) |
445 toHTMLFormControlElement(elements[i])->reset(); | 441 toHTMLFormControlElement(elements[i])->reset(); |
446 } | 442 } |
447 | 443 |
448 m_isInResetFunction = false; | 444 m_isInResetFunction = false; |
449 } | 445 } |
450 | 446 |
451 void HTMLFormElement::requestAutocomplete() | |
452 { | |
453 String errorMessage; | |
454 | |
455 if (!document().frame()) | |
456 errorMessage = "requestAutocomplete: form is not owned by a displayed do
cument."; | |
457 else if (!shouldAutocomplete()) | |
458 errorMessage = "requestAutocomplete: form autocomplete attribute is set
to off."; | |
459 else if (!UserGestureIndicator::utilizeUserGesture()) | |
460 errorMessage = "requestAutocomplete: must be called in response to a use
r gesture."; | |
461 | |
462 if (!errorMessage.isEmpty()) { | |
463 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour
ce, LogMessageLevel, errorMessage)); | |
464 finishRequestAutocomplete(AutocompleteResultErrorDisabled); | |
465 } else { | |
466 document().frame()->loader().client()->didRequestAutocomplete(this); | |
467 } | |
468 } | |
469 | |
470 void HTMLFormElement::finishRequestAutocomplete(AutocompleteResult result) | |
471 { | |
472 Event* event = nullptr; | |
473 if (result == AutocompleteResultSuccess) | |
474 event = Event::createBubble(EventTypeNames::autocomplete); | |
475 else if (result == AutocompleteResultErrorDisabled) | |
476 event = AutocompleteErrorEvent::create("disabled"); | |
477 else if (result == AutocompleteResultErrorCancel) | |
478 event = AutocompleteErrorEvent::create("cancel"); | |
479 else if (result == AutocompleteResultErrorInvalid) | |
480 event = AutocompleteErrorEvent::create("invalid"); | |
481 else | |
482 ASSERT_NOT_REACHED(); | |
483 | |
484 event->setTarget(this); | |
485 m_pendingAutocompleteEventsQueue->enqueueEvent(event); | |
486 } | |
487 | |
488 void HTMLFormElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& oldValue, const AtomicString& value) | 447 void HTMLFormElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& oldValue, const AtomicString& value) |
489 { | 448 { |
490 if (name == actionAttr) { | 449 if (name == actionAttr) { |
491 m_attributes.parseAction(value); | 450 m_attributes.parseAction(value); |
492 // If the new action attribute is pointing to insecure "action" location
from a secure page | 451 // If the new action attribute is pointing to insecure "action" location
from a secure page |
493 // it is marked as "passive" mixed content. | 452 // it is marked as "passive" mixed content. |
494 KURL actionURL = document().completeURL(m_attributes.action().isEmpty()
? document().url().getString() : m_attributes.action()); | 453 KURL actionURL = document().completeURL(m_attributes.action().isEmpty()
? document().url().getString() : m_attributes.action()); |
495 if (MixedContentChecker::isMixedFormAction(document().frame(), actionURL
)) | 454 if (MixedContentChecker::isMixedFormAction(document().frame(), actionURL
)) |
496 UseCounter::count(document().frame(), UseCounter::MixedContentFormPr
esent); | 455 UseCounter::count(document().frame(), UseCounter::MixedContentFormPr
esent); |
497 logUpdateAttributeIfIsolatedWorldAndInDocument("form", actionAttr, oldVa
lue, value); | 456 logUpdateAttributeIfIsolatedWorldAndInDocument("form", actionAttr, oldVa
lue, value); |
498 } else if (name == targetAttr) { | 457 } else if (name == targetAttr) { |
499 m_attributes.setTarget(value); | 458 m_attributes.setTarget(value); |
500 } else if (name == methodAttr) { | 459 } else if (name == methodAttr) { |
501 m_attributes.updateMethodType(value); | 460 m_attributes.updateMethodType(value); |
502 } else if (name == enctypeAttr) { | 461 } else if (name == enctypeAttr) { |
503 m_attributes.updateEncodingType(value); | 462 m_attributes.updateEncodingType(value); |
504 } else if (name == accept_charsetAttr) { | 463 } else if (name == accept_charsetAttr) { |
505 m_attributes.setAcceptCharset(value); | 464 m_attributes.setAcceptCharset(value); |
506 } else if (name == onautocompleteAttr) { | |
507 setAttributeEventListener(EventTypeNames::autocomplete, createAttributeE
ventListener(this, name, value, eventParameterName())); | |
508 } else if (name == onautocompleteerrorAttr) { | |
509 setAttributeEventListener(EventTypeNames::autocompleteerror, createAttri
buteEventListener(this, name, value, eventParameterName())); | |
510 } else { | 465 } else { |
511 HTMLElement::parseAttribute(name, oldValue, value); | 466 HTMLElement::parseAttribute(name, oldValue, value); |
512 } | 467 } |
513 } | 468 } |
514 | 469 |
515 void HTMLFormElement::associate(FormAssociatedElement& e) | 470 void HTMLFormElement::associate(FormAssociatedElement& e) |
516 { | 471 { |
517 m_associatedElementsAreDirty = true; | 472 m_associatedElementsAreDirty = true; |
518 m_associatedElements.clear(); | 473 m_associatedElements.clear(); |
519 if (toHTMLElement(e).fastHasAttribute(formAttr)) | 474 if (toHTMLElement(e).fastHasAttribute(formAttr)) |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 { | 770 { |
816 for (const auto& control : associatedElements()) { | 771 for (const auto& control : associatedElements()) { |
817 if (!control->isFormControlElement()) | 772 if (!control->isFormControlElement()) |
818 continue; | 773 continue; |
819 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton()) | 774 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton()) |
820 toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::P
seudoDefault); | 775 toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::P
seudoDefault); |
821 } | 776 } |
822 } | 777 } |
823 | 778 |
824 } // namespace blink | 779 } // namespace blink |
OLD | NEW |