| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the select element layoutObject in WebCore. | 2 * This file is part of the select element layoutObject in WebCore. |
| 3 * | 3 * |
| 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "platform/geometry/LayoutRect.h" | 31 #include "platform/geometry/LayoutRect.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class HTMLSelectElement; | 35 class HTMLSelectElement; |
| 36 class LayoutText; | 36 class LayoutText; |
| 37 | 37 |
| 38 class CORE_EXPORT LayoutMenuList final : public LayoutFlexibleBox, private Popup
MenuClient { | 38 class CORE_EXPORT LayoutMenuList final : public LayoutFlexibleBox, private Popup
MenuClient { |
| 39 public: | 39 public: |
| 40 explicit LayoutMenuList(Element*); | 40 explicit LayoutMenuList(Element*); |
| 41 virtual ~LayoutMenuList(); | 41 ~LayoutMenuList() override; |
| 42 | 42 |
| 43 bool popupIsVisible() const { return m_popupIsVisible; } | 43 bool popupIsVisible() const { return m_popupIsVisible; } |
| 44 void showPopup(); | 44 void showPopup(); |
| 45 void hidePopup(); | 45 void hidePopup(); |
| 46 PopupMenu* popup() const { return m_popup.get(); } | 46 PopupMenu* popup() const { return m_popup.get(); } |
| 47 | 47 |
| 48 void setOptionsChanged(bool changed) { m_optionsChanged = changed; } | 48 void setOptionsChanged(bool changed) { m_optionsChanged = changed; } |
| 49 | 49 |
| 50 void didSetSelectedIndex(int listIndex); | 50 void didSetSelectedIndex(int listIndex); |
| 51 | 51 |
| 52 String text() const; | 52 String text() const; |
| 53 | 53 |
| 54 virtual PopupMenuStyle itemStyle(unsigned listIndex) const override; | 54 PopupMenuStyle itemStyle(unsigned listIndex) const override; |
| 55 | 55 |
| 56 virtual const char* name() const override { return "LayoutMenuList"; } | 56 const char* name() const override { return "LayoutMenuList"; } |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 virtual void willBeDestroyed() override; | 59 void willBeDestroyed() override; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 HTMLSelectElement* selectElement() const; | 62 HTMLSelectElement* selectElement() const; |
| 63 | 63 |
| 64 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectMenuList || LayoutFlexibleBox::isOfType(type); } | 64 bool isOfType(LayoutObjectType type) const override { return type == LayoutO
bjectMenuList || LayoutFlexibleBox::isOfType(type); } |
| 65 virtual bool isChildAllowed(LayoutObject*, const ComputedStyle&) const overr
ide; | 65 bool isChildAllowed(LayoutObject*, const ComputedStyle&) const override; |
| 66 | 66 |
| 67 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nu
llptr) override; | 67 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) o
verride; |
| 68 virtual void removeChild(LayoutObject*) override; | 68 void removeChild(LayoutObject*) override; |
| 69 virtual bool createsAnonymousWrapper() const override { return true; } | 69 bool createsAnonymousWrapper() const override { return true; } |
| 70 | 70 |
| 71 virtual void updateFromElement() override; | 71 void updateFromElement() override; |
| 72 | 72 |
| 73 virtual LayoutRect controlClipRect(const LayoutPoint&) const override; | 73 LayoutRect controlClipRect(const LayoutPoint&) const override; |
| 74 virtual bool hasControlClip() const override { return true; } | 74 bool hasControlClip() const override { return true; } |
| 75 | 75 |
| 76 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const override; | 76 void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit&
maxLogicalWidth) const override; |
| 77 | 77 |
| 78 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle)
override; | 78 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; |
| 79 | 79 |
| 80 // PopupMenuClient methods | 80 // PopupMenuClient methods |
| 81 virtual void valueChanged(unsigned listIndex, bool fireOnChange = true) over
ride; | 81 void valueChanged(unsigned listIndex, bool fireOnChange = true) override; |
| 82 virtual void selectionChanged(unsigned, bool) override { } | 82 void selectionChanged(unsigned, bool) override { } |
| 83 virtual void selectionCleared() override { } | 83 void selectionCleared() override { } |
| 84 virtual String itemText(unsigned listIndex) const override; | 84 String itemText(unsigned listIndex) const override; |
| 85 virtual String itemToolTip(unsigned listIndex) const override; | 85 String itemToolTip(unsigned listIndex) const override; |
| 86 virtual String itemAccessibilityText(unsigned listIndex) const override; | 86 String itemAccessibilityText(unsigned listIndex) const override; |
| 87 virtual bool itemIsEnabled(unsigned listIndex) const override; | 87 bool itemIsEnabled(unsigned listIndex) const override; |
| 88 virtual PopupMenuStyle menuStyle() const override; | 88 PopupMenuStyle menuStyle() const override; |
| 89 virtual LayoutUnit clientPaddingLeft() const override; | 89 LayoutUnit clientPaddingLeft() const override; |
| 90 virtual LayoutUnit clientPaddingRight() const override; | 90 LayoutUnit clientPaddingRight() const override; |
| 91 virtual int listSize() const override; | 91 int listSize() const override; |
| 92 virtual int selectedIndex() const override; | 92 int selectedIndex() const override; |
| 93 virtual void popupDidHide() override; | 93 void popupDidHide() override; |
| 94 virtual void popupDidCancel() override; | 94 void popupDidCancel() override; |
| 95 virtual bool itemIsSeparator(unsigned listIndex) const override; | 95 bool itemIsSeparator(unsigned listIndex) const override; |
| 96 virtual bool itemIsLabel(unsigned listIndex) const override; | 96 bool itemIsLabel(unsigned listIndex) const override; |
| 97 virtual bool itemIsSelected(unsigned listIndex) const override; | 97 bool itemIsSelected(unsigned listIndex) const override; |
| 98 virtual void provisionalSelectionChanged(unsigned) override; | 98 void provisionalSelectionChanged(unsigned) override; |
| 99 virtual void listBoxSelectItem(int listIndex, bool allowMultiplySelections,
bool shift, bool fireOnChangeNow = true) override; | 99 void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shi
ft, bool fireOnChangeNow = true) override; |
| 100 virtual bool multiple() const override; | 100 bool multiple() const override; |
| 101 virtual IntRect elementRectRelativeToViewport() const override; | 101 IntRect elementRectRelativeToViewport() const override; |
| 102 virtual Element& ownerElement() const override; | 102 Element& ownerElement() const override; |
| 103 virtual const ComputedStyle* computedStyleForItem(Element&) const override; | 103 const ComputedStyle* computedStyleForItem(Element&) const override; |
| 104 | 104 |
| 105 virtual bool hasLineIfEmpty() const override { return true; } | 105 bool hasLineIfEmpty() const override { return true; } |
| 106 | 106 |
| 107 // Flexbox defines baselines differently than regular blocks. | 107 // Flexbox defines baselines differently than regular blocks. |
| 108 // For backwards compatibility, menulists need to do the regular block behav
ior. | 108 // For backwards compatibility, menulists need to do the regular block behav
ior. |
| 109 virtual int baselinePosition(FontBaseline baseline, bool firstLine, LineDire
ctionMode direction, LinePositionMode position) const override | 109 int baselinePosition(FontBaseline baseline, bool firstLine, LineDirectionMod
e direction, LinePositionMode position) const override |
| 110 { | 110 { |
| 111 return LayoutBlock::baselinePosition(baseline, firstLine, direction, pos
ition); | 111 return LayoutBlock::baselinePosition(baseline, firstLine, direction, pos
ition); |
| 112 } | 112 } |
| 113 virtual int firstLineBoxBaseline() const override { return LayoutBlock::firs
tLineBoxBaseline(); } | 113 int firstLineBoxBaseline() const override { return LayoutBlock::firstLineBox
Baseline(); } |
| 114 virtual int inlineBlockBaseline(LineDirectionMode direction) const override
{ return LayoutBlock::inlineBlockBaseline(direction); } | 114 int inlineBlockBaseline(LineDirectionMode direction) const override { return
LayoutBlock::inlineBlockBaseline(direction); } |
| 115 | 115 |
| 116 void getItemBackgroundColor(unsigned listIndex, Color&, bool& itemHasCustomB
ackgroundColor) const; | 116 void getItemBackgroundColor(unsigned listIndex, Color&, bool& itemHasCustomB
ackgroundColor) const; |
| 117 | 117 |
| 118 void createInnerBlock(); | 118 void createInnerBlock(); |
| 119 void adjustInnerStyle(); | 119 void adjustInnerStyle(); |
| 120 void setText(const String&); | 120 void setText(const String&); |
| 121 void setTextFromOption(int optionIndex); | 121 void setTextFromOption(int optionIndex); |
| 122 void updateOptionsWidth(); | 122 void updateOptionsWidth(); |
| 123 void updateText(); | 123 void updateText(); |
| 124 void setIndexToSelectOnCancel(int listIndex); | 124 void setIndexToSelectOnCancel(int listIndex); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 143 | 143 |
| 144 // TODO(tkent): Use FRIEND_TEST macro provided by gtest_prod.h | 144 // TODO(tkent): Use FRIEND_TEST macro provided by gtest_prod.h |
| 145 friend class LayoutMenuListTest_ElementRectRelativeToViewport_Test; | 145 friend class LayoutMenuListTest_ElementRectRelativeToViewport_Test; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutMenuList, isMenuList()); | 148 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutMenuList, isMenuList()); |
| 149 | 149 |
| 150 } | 150 } |
| 151 | 151 |
| 152 #endif | 152 #endif |
| OLD | NEW |