OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "web/ExternalPopupMenu.h" | 6 #include "web/ExternalPopupMenu.h" |
7 | 7 |
8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
9 #include "core/dom/NodeComputedStyle.h" | 9 #include "core/dom/NodeComputedStyle.h" |
10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 class TestPopupMenuClient : public PopupMenuClient { | 30 class TestPopupMenuClient : public PopupMenuClient { |
31 public: | 31 public: |
32 TestPopupMenuClient() { } | 32 TestPopupMenuClient() { } |
33 ~TestPopupMenuClient() override { } | 33 ~TestPopupMenuClient() override { } |
34 | 34 |
35 void valueChanged(unsigned listIndex, bool fireEvents = true) override { } | 35 void valueChanged(unsigned listIndex, bool fireEvents = true) override { } |
36 void selectionChanged(unsigned listIndex, bool fireEvents = true) override {
} | 36 void selectionChanged(unsigned listIndex, bool fireEvents = true) override {
} |
37 void selectionCleared() override { } | 37 void selectionCleared() override { } |
38 | 38 |
| 39 Element& itemElement(unsigned listIndex) const override { return *m_ownerEle
ment->listItems()[listIndex]; } |
39 String itemText(unsigned listIndex) const override { return emptyString(); } | 40 String itemText(unsigned listIndex) const override { return emptyString(); } |
40 String itemToolTip(unsigned listIndex) const override { return emptyString()
; } | 41 String itemToolTip(unsigned listIndex) const override { return emptyString()
; } |
41 String itemAccessibilityText(unsigned listIndex) const override { return emp
tyString(); } | 42 String itemAccessibilityText(unsigned listIndex) const override { return emp
tyString(); } |
42 bool itemIsEnabled(unsigned listIndex) const override { return true; } | 43 bool itemIsEnabled(unsigned listIndex) const override { return true; } |
43 LayoutUnit clientPaddingLeft() const override { return 0; } | 44 LayoutUnit clientPaddingLeft() const override { return 0; } |
44 LayoutUnit clientPaddingRight() const override { return 0; } | 45 LayoutUnit clientPaddingRight() const override { return 0; } |
45 int listSize() const override { return m_ownerElement->listItems().size(); } | 46 int listSize() const override { return m_ownerElement->listItems().size(); } |
46 int selectedIndex() const override { return 0; } | 47 int selectedIndex() const override { return 0; } |
47 void popupDidHide() override { } | 48 void popupDidHide() override { } |
48 void popupDidCancel() override { } | 49 void popupDidCancel() override { } |
49 bool itemIsSeparator(unsigned listIndex) const override { return false;} | 50 bool itemIsSeparator(unsigned listIndex) const override { return false;} |
50 bool itemIsLabel(unsigned listIndex) const override { return false; } | 51 bool itemIsLabel(unsigned listIndex) const override { return false; } |
51 bool itemIsSelected(unsigned listIndex) const override { return listIndex ==
0;} | 52 bool itemIsSelected(unsigned listIndex) const override { return listIndex ==
0;} |
52 bool itemIsDisplayNone(unsigned listIndex) const override { return computedS
tyleForItem(listIndex)->display() == NONE; } | 53 bool itemIsDisplayNone(unsigned listIndex) const override { return computedS
tyleForItem(listIndex)->display() == NONE; } |
53 void provisionalSelectionChanged(unsigned listIndex) override { } | 54 void provisionalSelectionChanged(unsigned listIndex) override { } |
54 bool multiple() const override { return false; } | 55 bool multiple() const override { return false; } |
55 IntRect elementRectRelativeToViewport() const override { return IntRect(); } | 56 IntRect elementRectRelativeToViewport() const override { return IntRect(); } |
56 Element& ownerElement() const override { return *m_ownerElement; } | 57 Element& ownerElement() const override { return *m_ownerElement; } |
57 const ComputedStyle* computedStyleForItem(Element& element) const override {
return nullptr; } | |
58 const ComputedStyle* computedStyleForItem(unsigned listIndex) const override | 58 const ComputedStyle* computedStyleForItem(unsigned listIndex) const override |
59 { | 59 { |
60 Element* element = m_ownerElement->listItems()[listIndex]; | 60 Element* element = m_ownerElement->listItems()[listIndex]; |
61 return element->computedStyle() ? element->computedStyle() : element->en
sureComputedStyle(); | 61 return element->computedStyle() ? element->computedStyle() : element->en
sureComputedStyle(); |
62 } | 62 } |
63 | 63 |
64 void setOwnerElement(PassRefPtrWillBeRawPtr<HTMLSelectElement> element) { m_
ownerElement = element; } | 64 void setOwnerElement(PassRefPtrWillBeRawPtr<HTMLSelectElement> element) { m_
ownerElement = element; } |
65 | 65 |
66 private: | 66 private: |
67 RefPtrWillBePersistent<HTMLSelectElement> m_ownerElement; | 67 RefPtrWillBePersistent<HTMLSelectElement> m_ownerElement; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ASSERT_TRUE(menuList->popupIsVisible()); | 252 ASSERT_TRUE(menuList->popupIsVisible()); |
253 | 253 |
254 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); | 254 WebExternalPopupMenuClient* client = static_cast<ExternalPopupMenu*>(menuLis
t->popup()); |
255 WebVector<int> indices; | 255 WebVector<int> indices; |
256 client->didAcceptIndices(indices); | 256 client->didAcceptIndices(indices); |
257 EXPECT_FALSE(menuList->popupIsVisible()); | 257 EXPECT_FALSE(menuList->popupIsVisible()); |
258 EXPECT_EQ(-1, select->selectedIndex()); | 258 EXPECT_EQ(-1, select->selectedIndex()); |
259 } | 259 } |
260 | 260 |
261 } // namespace blink | 261 } // namespace blink |
OLD | NEW |