Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: Source/modules/accessibility/AXMenuListOption.cpp

Issue 1072273006: Oilpan: Prepare moving AXObject to heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 21 matching lines...) Expand all
32 namespace blink { 32 namespace blink {
33 33
34 using namespace HTMLNames; 34 using namespace HTMLNames;
35 35
36 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, AXObjectCacheImpl & axObjectCache) 36 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, AXObjectCacheImpl & axObjectCache)
37 : AXMockObject(axObjectCache) 37 : AXMockObject(axObjectCache)
38 , m_element(element) 38 , m_element(element)
39 { 39 {
40 } 40 }
41 41
42 AXMenuListOption::~AXMenuListOption()
43 {
44 ASSERT(!m_element);
45 }
46
42 void AXMenuListOption::detach() 47 void AXMenuListOption::detach()
43 { 48 {
44 m_element = nullptr; 49 m_element = nullptr;
45 AXMockObject::detach(); 50 AXMockObject::detach();
46 } 51 }
47 52
48 Element* AXMenuListOption::actionElement() const 53 Element* AXMenuListOption::actionElement() const
49 { 54 {
50 return m_element; 55 return m_element;
51 } 56 }
52 57
53 bool AXMenuListOption::isEnabled() const 58 bool AXMenuListOption::isEnabled() const
54 { 59 {
55 // isDisabledFormControl() returns true if the parent <select> element is di sabled, 60 // isDisabledFormControl() returns true if the parent <select> element is di sabled,
56 // which we don't want. 61 // which we don't want.
57 return !m_element->ownElementDisabled(); 62 return m_element && !m_element->ownElementDisabled();
58 } 63 }
59 64
60 bool AXMenuListOption::isVisible() const 65 bool AXMenuListOption::isVisible() const
61 { 66 {
62 if (!m_parent) 67 if (!m_parent)
63 return false; 68 return false;
64 69
65 // In a single-option select with the popup collapsed, only the selected 70 // In a single-option select with the popup collapsed, only the selected
66 // item is considered visible. 71 // item is considered visible.
67 return !m_parent->isOffScreen() || isSelected(); 72 return !m_parent->isOffScreen() || isSelected();
68 } 73 }
69 74
70 bool AXMenuListOption::isOffScreen() const 75 bool AXMenuListOption::isOffScreen() const
71 { 76 {
72 // Invisible list options are considered to be offscreen. 77 // Invisible list options are considered to be offscreen.
73 return !isVisible(); 78 return !isVisible();
74 } 79 }
75 80
76 bool AXMenuListOption::isSelected() const 81 bool AXMenuListOption::isSelected() const
77 { 82 {
78 AXMenuListPopup* parent = static_cast<AXMenuListPopup*>(parentObject()); 83 AXMenuListPopup* parent = static_cast<AXMenuListPopup*>(parentObject());
79 if (parent && !parent->isOffScreen()) 84 if (parent && !parent->isOffScreen())
80 return parent->activeChild() == this; 85 return parent->activeChild() == this;
81 return m_element->selected(); 86 return m_element && m_element->selected();
82 } 87 }
83 88
84 void AXMenuListOption::setSelected(bool b) 89 void AXMenuListOption::setSelected(bool b)
85 { 90 {
86 if (!canSetSelectedAttribute()) 91 if (!m_element || !canSetSelectedAttribute())
87 return; 92 return;
88 93
89 m_element->setSelected(b); 94 m_element->setSelected(b);
90 } 95 }
91 96
92 bool AXMenuListOption::canSetSelectedAttribute() const 97 bool AXMenuListOption::canSetSelectedAttribute() const
93 { 98 {
94 return isEnabled(); 99 return isEnabled();
95 } 100 }
96 101
(...skipping 12 matching lines...) Expand all
109 AXObject* grandparent = parent->parentObject(); 114 AXObject* grandparent = parent->parentObject();
110 if (!grandparent) 115 if (!grandparent)
111 return LayoutRect(); 116 return LayoutRect();
112 ASSERT(grandparent->isMenuList()); 117 ASSERT(grandparent->isMenuList());
113 118
114 return grandparent->elementRect(); 119 return grandparent->elementRect();
115 } 120 }
116 121
117 String AXMenuListOption::stringValue() const 122 String AXMenuListOption::stringValue() const
118 { 123 {
119 return m_element->text(); 124 return m_element ? m_element->text() : String();
125 }
126
127 DEFINE_TRACE(AXMenuListOption)
128 {
129 visitor->trace(m_element);
130 AXMockObject::trace(visitor);
120 } 131 }
121 132
122 } // namespace blink 133 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXMenuListOption.h ('k') | Source/modules/accessibility/AXMenuListPopup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698