1 /*
2  * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
4  *               (http://www.torchmobile.com/)
5  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_
25 #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_
26 
27 #include "third_party/blink/renderer/core/layout/layout_text_control.h"
28 
29 namespace blink {
30 
31 // LayoutObject for text-field <input>s.
32 //
33 // This class inherits from LayoutTextControl and LayoutBlockFlow. If we'd like
34 // to change the base class, we need to make sure that
35 // ShouldIgnoreOverflowPropertyForInlineBlockBaseline flag works with the new
36 // base class.
37 class LayoutTextControlSingleLine : public LayoutTextControl {
38  public:
39   explicit LayoutTextControlSingleLine(Element*);
40   ~LayoutTextControlSingleLine() override;
41 
42  protected:
43   Element* ContainerElement() const;
44   Element* EditingViewPortElement() const;
45   HTMLInputElement* InputElement() const;
46 
47  private:
IsOfType(LayoutObjectType type)48   bool IsOfType(LayoutObjectType type) const override {
49     NOT_DESTROYED();
50     return type == kLayoutObjectTextControlSingleLine ||
51            LayoutTextControl::IsOfType(type);
52   }
53 
54   void Paint(const PaintInfo&) const override;
55   void UpdateLayout() override;
56 
57   bool NodeAtPoint(HitTestResult&,
58                    const HitTestLocation&,
59                    const PhysicalOffset& accumulated_offset,
60                    HitTestAction) final;
61 
62   int TextBlockWidth() const;
63 
64   void ComputeVisualOverflow(bool recompute_floats) override;
65 
66   // If the INPUT content height is smaller than the font height, the
67   // inner-editor element overflows the INPUT box intentionally, however it
68   // shouldn't affect outside of the INPUT box.  So we ignore child overflow.
AddLayoutOverflowFromChildren()69   void AddLayoutOverflowFromChildren() final { NOT_DESTROYED(); }
70 
AllowsNonVisibleOverflow()71   bool AllowsNonVisibleOverflow() const override {
72     NOT_DESTROYED();
73     return false;
74   }
75 
76   HTMLElement* InnerSpinButtonElement() const;
77 };
78 
79 // ----------------------------
80 
81 class LayoutTextControlInnerEditor : public LayoutBlockFlow {
82  public:
LayoutTextControlInnerEditor(Element * element)83   LayoutTextControlInnerEditor(Element* element) : LayoutBlockFlow(element) {
84     NOT_DESTROYED();
85   }
86 
87  private:
IsIntrinsicallyScrollable(ScrollbarOrientation orientation)88   bool IsIntrinsicallyScrollable(
89       ScrollbarOrientation orientation) const override {
90     NOT_DESTROYED();
91     return orientation == kHorizontalScrollbar;
92   }
ScrollsOverflowX()93   bool ScrollsOverflowX() const override {
94     NOT_DESTROYED();
95     return IsScrollContainer();
96   }
ScrollsOverflowY()97   bool ScrollsOverflowY() const override {
98     NOT_DESTROYED();
99     return false;
100   }
101 };
102 
103 }  // namespace blink
104 
105 #endif
106