OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Keep in sync with Actions in colorSuggestionPicker.js. | 40 // Keep in sync with Actions in colorSuggestionPicker.js. |
41 enum ColorPickerPopupAction { | 41 enum ColorPickerPopupAction { |
42 ColorPickerPopupActionChooseOtherColor = -2, | 42 ColorPickerPopupActionChooseOtherColor = -2, |
43 ColorPickerPopupActionCancel = -1, | 43 ColorPickerPopupActionCancel = -1, |
44 ColorPickerPopupActionSetValue = 0 | 44 ColorPickerPopupActionSetValue = 0 |
45 }; | 45 }; |
46 | 46 |
47 ColorChooserPopupUIController::ColorChooserPopupUIController(LocalFrame* frame,
ChromeClientImpl* chromeClient, ColorChooserClient* client) | 47 ColorChooserPopupUIController::ColorChooserPopupUIController(LocalFrame* frame,
ChromeClientImpl* chromeClient, ColorChooserClient* client) |
48 : ColorChooserUIController(frame, client) | 48 : ColorChooserUIController(frame, client) |
49 , m_chromeClient(chromeClient) | 49 , m_chromeClient(chromeClient) |
50 , m_popup(0) | 50 , m_popup(nullptr) |
51 , m_locale(Locale::defaultLocale()) | 51 , m_locale(Locale::defaultLocale()) |
52 { | 52 { |
| 53 #if ENABLE(OILPAN) |
| 54 ThreadState::current()->registerPreFinalizer(this); |
| 55 #endif |
53 } | 56 } |
54 | 57 |
55 ColorChooserPopupUIController::~ColorChooserPopupUIController() | 58 ColorChooserPopupUIController::~ColorChooserPopupUIController() |
56 { | 59 { |
| 60 #if !ENABLE(OILPAN) |
57 closePopup(); | 61 closePopup(); |
| 62 #endif |
58 // ~ColorChooserUIController ends the ColorChooser. | 63 // ~ColorChooserUIController ends the ColorChooser. |
59 } | 64 } |
60 | 65 |
| 66 void ColorChooserPopupUIController::dispose() |
| 67 { |
| 68 // Finalized earlier so as to access m_chromeClient while alive. |
| 69 closePopup(); |
| 70 } |
| 71 |
| 72 DEFINE_TRACE(ColorChooserPopupUIController) |
| 73 { |
| 74 visitor->trace(m_chromeClient); |
| 75 ColorChooserUIController::trace(visitor); |
| 76 } |
| 77 |
61 void ColorChooserPopupUIController::openUI() | 78 void ColorChooserPopupUIController::openUI() |
62 { | 79 { |
63 if (m_client->shouldShowSuggestions()) | 80 if (m_client->shouldShowSuggestions()) |
64 openPopup(); | 81 openPopup(); |
65 else | 82 else |
66 openColorChooser(); | 83 openColorChooser(); |
67 } | 84 } |
68 | 85 |
69 void ColorChooserPopupUIController::endChooser() | 86 void ColorChooserPopupUIController::endChooser() |
70 { | 87 { |
71 if (m_chooser) | 88 if (m_chooser) |
72 m_chooser->endChooser(); | 89 m_chooser->endChooser(); |
73 | 90 |
74 closePopup(); | 91 closePopup(); |
75 } | 92 } |
76 | 93 |
77 AXObject* ColorChooserPopupUIController::rootAXObject() | 94 AXObject* ColorChooserPopupUIController::rootAXObject() |
78 { | 95 { |
79 return m_popup ? m_popup->rootAXObject() : 0; | 96 return m_popup ? m_popup->rootAXObject() : nullptr; |
80 } | 97 } |
81 | 98 |
82 void ColorChooserPopupUIController::writeDocument(SharedBuffer* data) | 99 void ColorChooserPopupUIController::writeDocument(SharedBuffer* data) |
83 { | 100 { |
84 Vector<ColorSuggestion> suggestions = m_client->suggestions(); | 101 Vector<ColorSuggestion> suggestions = m_client->suggestions(); |
85 Vector<String> suggestionValues; | 102 Vector<String> suggestionValues; |
86 for (unsigned i = 0; i < suggestions.size(); i++) | 103 for (unsigned i = 0; i < suggestions.size(); i++) |
87 suggestionValues.append(suggestions[i].color.serialized()); | 104 suggestionValues.append(suggestions[i].color.serialized()); |
88 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(m_client->elem
entRectRelativeToViewport()); | 105 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(m_client->elem
entRectRelativeToViewport()); |
89 | 106 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 { | 138 { |
122 ASSERT(m_client); | 139 ASSERT(m_client); |
123 Color color; | 140 Color color; |
124 bool success = color.setFromString(value); | 141 bool success = color.setFromString(value); |
125 ASSERT_UNUSED(success, success); | 142 ASSERT_UNUSED(success, success); |
126 m_client->didChooseColor(color); | 143 m_client->didChooseColor(color); |
127 } | 144 } |
128 | 145 |
129 void ColorChooserPopupUIController::didClosePopup() | 146 void ColorChooserPopupUIController::didClosePopup() |
130 { | 147 { |
131 m_popup = 0; | 148 m_popup = nullptr; |
132 | 149 |
133 if (!m_chooser) | 150 if (!m_chooser) |
134 didEndChooser(); | 151 didEndChooser(); |
135 } | 152 } |
136 | 153 |
137 Element& ColorChooserPopupUIController::ownerElement() | 154 Element& ColorChooserPopupUIController::ownerElement() |
138 { | 155 { |
139 return m_client->ownerElement(); | 156 return m_client->ownerElement(); |
140 } | 157 } |
141 | 158 |
142 void ColorChooserPopupUIController::openPopup() | 159 void ColorChooserPopupUIController::openPopup() |
143 { | 160 { |
144 ASSERT(!m_popup); | 161 ASSERT(!m_popup); |
145 m_popup = m_chromeClient->openPagePopup(this); | 162 m_popup = m_chromeClient->openPagePopup(this); |
146 } | 163 } |
147 | 164 |
148 void ColorChooserPopupUIController::closePopup() | 165 void ColorChooserPopupUIController::closePopup() |
149 { | 166 { |
150 if (!m_popup) | 167 if (!m_popup) |
151 return; | 168 return; |
152 m_chromeClient->closePagePopup(m_popup); | 169 m_chromeClient->closePagePopup(m_popup); |
153 } | 170 } |
154 | 171 |
155 } // namespace blink | 172 } // namespace blink |
OLD | NEW |