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

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, 6 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 Element* AXMenuListOption::actionElement() const 48 Element* AXMenuListOption::actionElement() const
49 { 49 {
50 return m_element; 50 return m_element;
51 } 51 }
52 52
53 bool AXMenuListOption::isEnabled() const 53 bool AXMenuListOption::isEnabled() const
54 { 54 {
55 // isDisabledFormControl() returns true if the parent <select> element is di sabled, 55 // isDisabledFormControl() returns true if the parent <select> element is di sabled,
56 // which we don't want. 56 // which we don't want.
57 return !m_element->ownElementDisabled(); 57 return m_element && !m_element->ownElementDisabled();
58 } 58 }
59 59
60 bool AXMenuListOption::isVisible() const 60 bool AXMenuListOption::isVisible() const
61 { 61 {
62 if (!m_parent) 62 if (!m_parent)
63 return false; 63 return false;
64 64
65 // In a single-option select with the popup collapsed, only the selected 65 // In a single-option select with the popup collapsed, only the selected
66 // item is considered visible. 66 // item is considered visible.
67 return !m_parent->isOffScreen() || isSelected(); 67 return !m_parent->isOffScreen() || isSelected();
68 } 68 }
69 69
70 bool AXMenuListOption::isOffScreen() const 70 bool AXMenuListOption::isOffScreen() const
71 { 71 {
72 // Invisible list options are considered to be offscreen. 72 // Invisible list options are considered to be offscreen.
73 return !isVisible(); 73 return !isVisible();
74 } 74 }
75 75
76 bool AXMenuListOption::isSelected() const 76 bool AXMenuListOption::isSelected() const
77 { 77 {
78 AXMenuListPopup* parent = static_cast<AXMenuListPopup*>(parentObject()); 78 AXMenuListPopup* parent = static_cast<AXMenuListPopup*>(parentObject());
79 if (parent && !parent->isOffScreen()) 79 if (parent && !parent->isOffScreen())
80 return parent->activeChild() == this; 80 return parent->activeChild() == this;
81 return m_element->selected(); 81 return m_element && m_element->selected();
82 } 82 }
83 83
84 void AXMenuListOption::setSelected(bool b) 84 void AXMenuListOption::setSelected(bool b)
85 { 85 {
86 if (!canSetSelectedAttribute()) 86 if (!m_element || !canSetSelectedAttribute())
87 return; 87 return;
88 88
89 m_element->setSelected(b); 89 m_element->setSelected(b);
90 } 90 }
91 91
92 bool AXMenuListOption::canSetSelectedAttribute() const 92 bool AXMenuListOption::canSetSelectedAttribute() const
93 { 93 {
94 return isEnabled(); 94 return isEnabled();
95 } 95 }
96 96
97 bool AXMenuListOption::computeAccessibilityIsIgnored(IgnoredReasons* ignoredReas ons) const 97 bool AXMenuListOption::computeAccessibilityIsIgnored(IgnoredReasons* ignoredReas ons) const
98 { 98 {
99 return accessibilityIsIgnoredByDefault(ignoredReasons); 99 return accessibilityIsIgnoredByDefault(ignoredReasons);
100 } 100 }
101 101
102 LayoutRect AXMenuListOption::elementRect() const 102 LayoutRect AXMenuListOption::elementRect() const
103 { 103 {
104 AXObject* parent = parentObject(); 104 AXObject* parent = parentObject();
105 ASSERT(parent->isMenuListPopup()); 105 ASSERT(parent->isMenuListPopup());
106 106
107 AXObject* grandparent = parent->parentObject(); 107 AXObject* grandparent = parent->parentObject();
108 ASSERT(grandparent->isMenuList()); 108 ASSERT(grandparent->isMenuList());
109 109
110 return grandparent->elementRect(); 110 return grandparent->elementRect();
111 } 111 }
112 112
113 String AXMenuListOption::stringValue() const 113 String AXMenuListOption::stringValue() const
114 { 114 {
115 return m_element->text(); 115 return m_element ? m_element->text() : String();
116 }
117
118 DEFINE_TRACE(AXMenuListOption)
119 {
120 visitor->trace(m_element);
121 AXMockObject::trace(visitor);
116 } 122 }
117 123
118 } // namespace blink 124 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698