| OLD | NEW |
| 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 Loading... |
| 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 23 matching lines...) Expand all Loading... |
| 135 void ExternalPopupMenu::hide() | 132 void ExternalPopupMenu::hide() |
| 136 { | 133 { |
| 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(UpdateReason reason) |
| 146 { | 143 { |
| 147 if (m_needsUpdate) | 144 switch (reason) { |
| 148 return; | 145 case BySelectionChange: |
| 149 // TOOD(tkent): Even if DOMTreeVersion is not changed, we should update the | 146 case ByDOMChange: |
| 150 // popup location/content in some cases. e.g. Updating ComputedStyle of the | 147 if (m_needsUpdate) |
| 151 // SELECT element affects popup position and OPTION style. | 148 return; |
| 152 if (m_shownDOMTreeVersion == m_ownerElement->document().domTreeVersion()) | 149 m_needsUpdate = true; |
| 153 return; | 150 m_ownerElement->document().postTask(BLINK_FROM_HERE, createSameThreadTas
k(&ExternalPopupMenu::update, this)); |
| 154 m_needsUpdate = true; | 151 break; |
| 155 m_ownerElement->document().postTask(BLINK_FROM_HERE, createSameThreadTask(&E
xternalPopupMenu::update, this)); | 152 |
| 153 case ByStyleChange: |
| 154 // TOOD(tkent): We should update the popup location/content in some |
| 155 // cases. e.g. Updating ComputedStyle of the SELECT element affects |
| 156 // popup position and OPTION style. |
| 157 break; |
| 158 } |
| 156 } | 159 } |
| 157 | 160 |
| 158 void ExternalPopupMenu::update() | 161 void ExternalPopupMenu::update() |
| 159 { | 162 { |
| 160 if (!m_webExternalPopupMenu || !m_ownerElement) | 163 if (!m_webExternalPopupMenu || !m_ownerElement) |
| 161 return; | 164 return; |
| 162 m_ownerElement->document().updateLayoutTree(); | 165 m_ownerElement->document().updateLayoutTree(); |
| 163 // disconnectClient() might have been called. | 166 // disconnectClient() might have been called. |
| 164 if (!m_ownerElement) | 167 if (!m_ownerElement) |
| 165 return; | 168 return; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (ownerElement.itemIsDisplayNone(*items[i])) | 293 if (ownerElement.itemIsDisplayNone(*items[i])) |
| 291 continue; | 294 continue; |
| 292 if (popupMenuItemIndex == i) | 295 if (popupMenuItemIndex == i) |
| 293 return indexTracker; | 296 return indexTracker; |
| 294 ++indexTracker; | 297 ++indexTracker; |
| 295 } | 298 } |
| 296 return -1; | 299 return -1; |
| 297 } | 300 } |
| 298 | 301 |
| 299 } // namespace blink | 302 } // namespace blink |
| OLD | NEW |