| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "core/CoreExport.h" | 25 #include "core/CoreExport.h" |
| 26 #include "core/layout/LayoutBlockFlow.h" | 26 #include "core/layout/LayoutBlockFlow.h" |
| 27 #include "core/layout/LayoutFlexibleBox.h" | 27 #include "core/layout/LayoutFlexibleBox.h" |
| 28 | 28 |
| 29 namespace blink { | 29 namespace blink { |
| 30 | 30 |
| 31 class HTMLTextFormControlElement; | 31 class HTMLTextFormControlElement; |
| 32 | 32 |
| 33 class CORE_EXPORT LayoutTextControl : public LayoutBlockFlow { | 33 class CORE_EXPORT LayoutTextControl : public LayoutBlockFlow { |
| 34 public: | 34 public: |
| 35 virtual ~LayoutTextControl(); | 35 ~LayoutTextControl() override; |
| 36 | 36 |
| 37 HTMLTextFormControlElement* textFormControlElement() const; | 37 HTMLTextFormControlElement* textFormControlElement() const; |
| 38 virtual PassRefPtr<ComputedStyle> createInnerEditorStyle(const ComputedStyle
& startStyle) const = 0; | 38 virtual PassRefPtr<ComputedStyle> createInnerEditorStyle(const ComputedStyle
& startStyle) const = 0; |
| 39 | 39 |
| 40 virtual const char* name() const override { return "LayoutTextControl"; } | 40 const char* name() const override { return "LayoutTextControl"; } |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 LayoutTextControl(HTMLTextFormControlElement*); | 43 LayoutTextControl(HTMLTextFormControlElement*); |
| 44 | 44 |
| 45 // This convenience function should not be made public because | 45 // This convenience function should not be made public because |
| 46 // innerEditorElement may outlive the layout tree. | 46 // innerEditorElement may outlive the layout tree. |
| 47 HTMLElement* innerEditorElement() const; | 47 HTMLElement* innerEditorElement() const; |
| 48 | 48 |
| 49 int scrollbarThickness() const; | 49 int scrollbarThickness() const; |
| 50 void adjustInnerEditorStyle(ComputedStyle& textBlockStyle) const; | 50 void adjustInnerEditorStyle(ComputedStyle& textBlockStyle) const; |
| 51 | 51 |
| 52 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle)
override; | 52 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; |
| 53 | 53 |
| 54 void hitInnerEditorElement(HitTestResult&, const LayoutPoint& pointInContain
er, const LayoutPoint& accumulatedOffset); | 54 void hitInnerEditorElement(HitTestResult&, const LayoutPoint& pointInContain
er, const LayoutPoint& accumulatedOffset); |
| 55 | 55 |
| 56 int textBlockLogicalWidth() const; | 56 int textBlockLogicalWidth() const; |
| 57 int textBlockLogicalHeight() const; | 57 int textBlockLogicalHeight() const; |
| 58 | 58 |
| 59 float scaleEmToUnits(int x) const; | 59 float scaleEmToUnits(int x) const; |
| 60 | 60 |
| 61 static bool hasValidAvgCharWidth(AtomicString family); | 61 static bool hasValidAvgCharWidth(AtomicString family); |
| 62 virtual float getAvgCharWidth(AtomicString family); | 62 virtual float getAvgCharWidth(AtomicString family); |
| 63 virtual LayoutUnit preferredContentLogicalWidth(float charWidth) const = 0; | 63 virtual LayoutUnit preferredContentLogicalWidth(float charWidth) const = 0; |
| 64 virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, Layout
Unit nonContentHeight) const = 0; | 64 virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, Layout
Unit nonContentHeight) const = 0; |
| 65 | 65 |
| 66 virtual void updateFromElement() override; | 66 void updateFromElement() override; |
| 67 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const override; | 67 void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, L
ogicalExtentComputedValues&) const override; |
| 68 virtual LayoutObject* layoutSpecialExcludedChild(bool relayoutChildren, Subt
reeLayoutScope&) override; | 68 LayoutObject* layoutSpecialExcludedChild(bool relayoutChildren, SubtreeLayou
tScope&) override; |
| 69 | 69 |
| 70 // We need to override this function because we don't want overflow:hidden o
n an <input> | 70 // We need to override this function because we don't want overflow:hidden o
n an <input> |
| 71 // to affect the baseline calculation. This is necessary because we are an i
nline-block | 71 // to affect the baseline calculation. This is necessary because we are an i
nline-block |
| 72 // element as an implementation detail which would normally be affected by t
his. | 72 // element as an implementation detail which would normally be affected by t
his. |
| 73 virtual int inlineBlockBaseline(LineDirectionMode direction) const override
{ return lastLineBoxBaseline(direction); } | 73 int inlineBlockBaseline(LineDirectionMode direction) const override { return
lastLineBoxBaseline(direction); } |
| 74 | 74 |
| 75 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectTextControl || LayoutBlockFlow::isOfType(type); } | 75 bool isOfType(LayoutObjectType type) const override { return type == LayoutO
bjectTextControl || LayoutBlockFlow::isOfType(type); } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const override final; | 78 void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit&
maxLogicalWidth) const final; |
| 79 virtual void computePreferredLogicalWidths() override final; | 79 void computePreferredLogicalWidths() final; |
| 80 virtual void removeLeftoverAnonymousBlock(LayoutBlock*) override final { } | 80 void removeLeftoverAnonymousBlock(LayoutBlock*) final { } |
| 81 virtual bool avoidsFloats() const override final { return true; } | 81 bool avoidsFloats() const final { return true; } |
| 82 | 82 |
| 83 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nu
llptr) override final; | 83 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) f
inal; |
| 84 | 84 |
| 85 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit
ionalOffset) const override final; | 85 void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOff
set) const final; |
| 86 | 86 |
| 87 virtual bool canBeProgramaticallyScrolled() const override final { return tr
ue; } | 87 bool canBeProgramaticallyScrolled() const final { return true; } |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTextControl, isTextControl()); | 90 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTextControl, isTextControl()); |
| 91 | 91 |
| 92 // LayoutObject for our inner container, for <search> and others. | 92 // LayoutObject for our inner container, for <search> and others. |
| 93 // We can't use LayoutFlexibleBox directly, because flexboxes have a different | 93 // We can't use LayoutFlexibleBox directly, because flexboxes have a different |
| 94 // baseline definition, and then inputs of different types wouldn't line up | 94 // baseline definition, and then inputs of different types wouldn't line up |
| 95 // anymore. | 95 // anymore. |
| 96 class LayoutTextControlInnerContainer final : public LayoutFlexibleBox { | 96 class LayoutTextControlInnerContainer final : public LayoutFlexibleBox { |
| 97 public: | 97 public: |
| 98 explicit LayoutTextControlInnerContainer(Element* element) | 98 explicit LayoutTextControlInnerContainer(Element* element) |
| 99 : LayoutFlexibleBox(element) | 99 : LayoutFlexibleBox(element) |
| 100 { } | 100 { } |
| 101 virtual ~LayoutTextControlInnerContainer() { } | 101 ~LayoutTextControlInnerContainer() override { } |
| 102 | 102 |
| 103 virtual int baselinePosition(FontBaseline baseline, bool firstLine, LineDire
ctionMode direction, LinePositionMode position) const override | 103 int baselinePosition(FontBaseline baseline, bool firstLine, LineDirectionMod
e direction, LinePositionMode position) const override |
| 104 { | 104 { |
| 105 return LayoutBlock::baselinePosition(baseline, firstLine, direction, pos
ition); | 105 return LayoutBlock::baselinePosition(baseline, firstLine, direction, pos
ition); |
| 106 } | 106 } |
| 107 virtual int firstLineBoxBaseline() const override { return LayoutBlock::firs
tLineBoxBaseline(); } | 107 int firstLineBoxBaseline() const override { return LayoutBlock::firstLineBox
Baseline(); } |
| 108 virtual int inlineBlockBaseline(LineDirectionMode direction) const override
{ return lastLineBoxBaseline(direction); } | 108 int inlineBlockBaseline(LineDirectionMode direction) const override { return
lastLineBoxBaseline(direction); } |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 | 111 |
| 112 } // namespace blink | 112 } // namespace blink |
| 113 | 113 |
| 114 #endif // LayoutTextControl_h | 114 #endif // LayoutTextControl_h |
| OLD | NEW |