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

Side by Side Diff: third_party/WebKit/Source/web/ExternalPopupMenu.cpp

Issue 1970653003: ExternalPopupMenu should recreate its popup only if a SELECT subtree is updated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ExternalPopupMenu::m_shownDOMTreeVersion Created 4 years, 7 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 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return false; 88 return false;
89 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(m_localFrame.get( )); 89 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(m_localFrame.get( ));
90 m_webExternalPopupMenu = webframe->client()->createExternalPopupMenu(info, t his); 90 m_webExternalPopupMenu = webframe->client()->createExternalPopupMenu(info, t his);
91 if (m_webExternalPopupMenu) { 91 if (m_webExternalPopupMenu) {
92 LayoutObject* layoutObject = m_ownerElement->layoutObject(); 92 LayoutObject* layoutObject = m_ownerElement->layoutObject();
93 if (!layoutObject || !layoutObject->isBox()) 93 if (!layoutObject || !layoutObject->isBox())
94 return false; 94 return false;
95 FloatQuad quad(toLayoutBox(layoutObject)->localToAbsoluteQuad(FloatQuad( toLayoutBox(layoutObject)->borderBoundingBox()))); 95 FloatQuad quad(toLayoutBox(layoutObject)->localToAbsoluteQuad(FloatQuad( toLayoutBox(layoutObject)->borderBoundingBox())));
96 IntRect rect(quad.enclosingBoundingBox()); 96 IntRect rect(quad.enclosingBoundingBox());
97 IntRect rectInViewport = m_localFrame->view()->soonToBeRemovedContentsTo UnscaledViewport(rect); 97 IntRect rectInViewport = m_localFrame->view()->soonToBeRemovedContentsTo UnscaledViewport(rect);
98 // TODO(tkent): If the anchor rectangle is not visible, we should not
99 // show a popup.
100 m_webExternalPopupMenu->show(rectInViewport); 98 m_webExternalPopupMenu->show(rectInViewport);
101 m_shownDOMTreeVersion = m_ownerElement->document().domTreeVersion();
102 return true; 99 return true;
103 } else { 100 } else {
104 // The client might refuse to create a popup (when there is already one pending to be shown for example). 101 // The client might refuse to create a popup (when there is already one pending to be shown for example).
105 didCancel(); 102 didCancel();
106 return false; 103 return false;
107 } 104 }
108 } 105 }
109 106
110 void ExternalPopupMenu::show() 107 void ExternalPopupMenu::show()
111 { 108 {
(...skipping 25 matching lines...) Expand all
137 if (m_ownerElement) 134 if (m_ownerElement)
138 m_ownerElement->popupDidHide(); 135 m_ownerElement->popupDidHide();
139 if (!m_webExternalPopupMenu) 136 if (!m_webExternalPopupMenu)
140 return; 137 return;
141 m_webExternalPopupMenu->close(); 138 m_webExternalPopupMenu->close();
142 m_webExternalPopupMenu = 0; 139 m_webExternalPopupMenu = 0;
143 } 140 }
144 141
145 void ExternalPopupMenu::updateFromElement() 142 void ExternalPopupMenu::updateFromElement()
146 { 143 {
147 if (m_needsUpdate) 144 // TOOD(tkent): Even if DOM mutation didn't happen, we should update the
148 return;
149 // TOOD(tkent): Even if DOMTreeVersion is not changed, we should update the
150 // popup location/content in some cases. e.g. Updating ComputedStyle of the 145 // popup location/content in some cases. e.g. Updating ComputedStyle of the
151 // SELECT element affects popup position and OPTION style. 146 // SELECT element affects popup position and OPTION style.
152 if (m_shownDOMTreeVersion == m_ownerElement->document().domTreeVersion()) 147 }
148
149 void ExternalPopupMenu::updateFromElementWithMutation()
150 {
151 if (m_needsUpdate)
153 return; 152 return;
154 m_needsUpdate = true; 153 m_needsUpdate = true;
155 m_ownerElement->document().postTask(BLINK_FROM_HERE, createSameThreadTask(&E xternalPopupMenu::update, this)); 154 m_ownerElement->document().postTask(BLINK_FROM_HERE, createSameThreadTask(&E xternalPopupMenu::update, this));
156 } 155 }
157 156
158 void ExternalPopupMenu::update() 157 void ExternalPopupMenu::update()
159 { 158 {
160 if (!m_webExternalPopupMenu || !m_ownerElement) 159 if (!m_webExternalPopupMenu || !m_ownerElement)
161 return; 160 return;
162 m_ownerElement->document().updateLayoutTree(); 161 m_ownerElement->document().updateLayoutTree();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (ownerElement.itemIsDisplayNone(*items[i])) 289 if (ownerElement.itemIsDisplayNone(*items[i]))
291 continue; 290 continue;
292 if (popupMenuItemIndex == i) 291 if (popupMenuItemIndex == i)
293 return indexTracker; 292 return indexTracker;
294 ++indexTracker; 293 ++indexTracker;
295 } 294 }
296 return -1; 295 return -1;
297 } 296 }
298 297
299 } // namespace blink 298 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698