1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  * Copyright (C) 2011 Apple Inc. All rights reserved.
4  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  *     * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_FORMS_IMAGE_INPUT_TYPE_H_
34 #define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_FORMS_IMAGE_INPUT_TYPE_H_
35 
36 #include "third_party/blink/renderer/core/html/forms/base_button_input_type.h"
37 #include "third_party/blink/renderer/platform/geometry/int_point.h"
38 
39 namespace blink {
40 
41 class ImageInputType final : public BaseButtonInputType {
42  public:
43   explicit ImageInputType(HTMLInputElement&);
44   void CustomStyleForLayoutObject(ComputedStyle& style) override;
45 
46  private:
47   void CountUsage() override;
48   const AtomicString& FormControlType() const override;
49   bool IsFormDataAppendable() const override;
50   void AppendToFormData(FormData&) const override;
51   String ResultForDialogSubmit() const override;
52   bool SupportsValidation() const override;
53   LayoutObject* CreateLayoutObject(const ComputedStyle&,
54                                    LegacyLayout) const override;
55   void HandleDOMActivateEvent(Event&) override;
56   void AltAttributeChanged() override;
57   void SrcAttributeChanged() override;
58   void ValueAttributeChanged() override;
59   void StartResourceLoading() override;
60   void OnAttachWithLayoutObject() override;
61   bool ShouldRespectAlignAttribute() override;
62   bool CanBeSuccessfulSubmitButton() override;
63   bool IsEnumeratable() override;
64   bool ShouldRespectHeightAndWidthAttributes() override;
65   unsigned Height() const override;
66   unsigned Width() const override;
67   bool HasLegalLinkAttribute(const QualifiedName&) const override;
68   const QualifiedName& SubResourceAttributeName() const override;
69   void EnsureFallbackContent() override;
70   void EnsurePrimaryContent() override;
71   void CreateShadowSubtree() override;
72 
73   void ReattachFallbackContent();
74   void SetUseFallbackContent();
HasFallbackContent()75   bool HasFallbackContent() const override { return use_fallback_content_; }
76 
77   // Valid only during HTMLFormElement::prepareForSubmission().
78   IntPoint click_location_;
79 
80   bool use_fallback_content_;
81 };
82 
83 }  // namespace blink
84 
85 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_FORMS_IMAGE_INPUT_TYPE_H_
86