1967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch/*
2967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * Copyright (C) 2010 Google Inc. All rights reserved.
3967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
4967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * Redistribution and use in source and binary forms, with or without
5967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * modification, are permitted provided that the following conditions are
6967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * met:
7967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
8967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Redistributions of source code must retain the above copyright
9967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * notice, this list of conditions and the following disclaimer.
10967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Redistributions in binary form must reproduce the above
11967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * copyright notice, this list of conditions and the following disclaimer
12967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * in the documentation and/or other materials provided with the
13967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * distribution.
14967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Neither the name of Google Inc. nor the names of its
15967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * contributors may be used to endorse or promote products derived from
16967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * this software without specific prior written permission.
17967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
18967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch */
30967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
31967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch#include "config.h"
32bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#include "IsIndexInputType.h"
33967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
34cad810f21b803229eb11403f9209855525a25d57Steve Block#include "Document.h"
35cad810f21b803229eb11403f9209855525a25d57Steve Block#include "HTMLFormElement.h"
36cad810f21b803229eb11403f9209855525a25d57Steve Block#include "HTMLInputElement.h"
37bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#include <wtf/PassOwnPtr.h>
38967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
39967717af5423377c967781471ee106e2bb4e11c8Ben Murdochnamespace WebCore {
40967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
41bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian MonsenPassOwnPtr<InputType> IsIndexInputType::create(HTMLInputElement* element)
42967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
43bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    return adoptPtr(new IsIndexInputType(element));
44967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
45967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
46bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& IsIndexInputType::formControlType() const
47967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch{
48bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    return emptyAtom;
49967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch}
50967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
51a94275402997c11dd2e778633dacf4b7e630a35dBen Murdochbool IsIndexInputType::supportsRequired() const
52a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch{
53a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    return false;
54a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch}
55a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch
56cad810f21b803229eb11403f9209855525a25d57Steve BlockPassRefPtr<HTMLFormElement> IsIndexInputType::formForSubmission() const
57cad810f21b803229eb11403f9209855525a25d57Steve Block{
58cad810f21b803229eb11403f9209855525a25d57Steve Block    RefPtr<HTMLFormElement> form = InputType::formForSubmission();
59cad810f21b803229eb11403f9209855525a25d57Steve Block    if (form)
60cad810f21b803229eb11403f9209855525a25d57Steve Block        return form.release();
61cad810f21b803229eb11403f9209855525a25d57Steve Block    // If there is no form, then create a temporary form just to be used for submission.
62cad810f21b803229eb11403f9209855525a25d57Steve Block    Document* document = element()->document();
63cad810f21b803229eb11403f9209855525a25d57Steve Block    form = HTMLFormElement::create(document);
64cad810f21b803229eb11403f9209855525a25d57Steve Block    form->registerFormElement(element());
65cad810f21b803229eb11403f9209855525a25d57Steve Block    form->setMethod("GET");
66cad810f21b803229eb11403f9209855525a25d57Steve Block    if (!document->baseURL().isEmpty()) {
67cad810f21b803229eb11403f9209855525a25d57Steve Block        // We treat the href property of the <base> element as the form action, as per section 7.5
68cad810f21b803229eb11403f9209855525a25d57Steve Block        // "Queries and Indexes" of the HTML 2.0 spec. <http://www.w3.org/MarkUp/html-spec/html-spec_7.html#SEC7.5>.
69cad810f21b803229eb11403f9209855525a25d57Steve Block        form->setAction(document->baseURL().string());
70cad810f21b803229eb11403f9209855525a25d57Steve Block    }
71cad810f21b803229eb11403f9209855525a25d57Steve Block    return form.release();
72cad810f21b803229eb11403f9209855525a25d57Steve Block}
73cad810f21b803229eb11403f9209855525a25d57Steve Block
74cad810f21b803229eb11403f9209855525a25d57Steve Blockbool IsIndexInputType::shouldRespectListAttribute()
75cad810f21b803229eb11403f9209855525a25d57Steve Block{
76cad810f21b803229eb11403f9209855525a25d57Steve Block    return false;
77cad810f21b803229eb11403f9209855525a25d57Steve Block}
78cad810f21b803229eb11403f9209855525a25d57Steve Block
79967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch} // namespace WebCore
80