| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "web/PopupMenuImpl.h" | 5 #include "web/PopupMenuImpl.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/css/CSSFontSelector.h" | 8 #include "core/css/CSSFontSelector.h" |
| 9 #include "core/dom/ElementTraversal.h" | 9 #include "core/dom/ElementTraversal.h" |
| 10 #include "core/dom/ExecutionContextTask.h" | 10 #include "core/dom/ExecutionContextTask.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 DEFINE_TRACE(PopupMenuImpl) | 239 DEFINE_TRACE(PopupMenuImpl) |
| 240 { | 240 { |
| 241 visitor->trace(m_chromeClient); | 241 visitor->trace(m_chromeClient); |
| 242 visitor->trace(m_ownerElement); | 242 visitor->trace(m_ownerElement); |
| 243 PopupMenu::trace(visitor); | 243 PopupMenu::trace(visitor); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void PopupMenuImpl::writeDocument(SharedBuffer* data) | 246 void PopupMenuImpl::writeDocument(SharedBuffer* data) |
| 247 { | 247 { |
| 248 HTMLSelectElement& ownerElement = *m_ownerElement; | 248 HTMLSelectElement& ownerElement = *m_ownerElement; |
| 249 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(ownerElement.e
lementRectRelativeToViewport(), ownerElement.document().view()); | 249 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(ownerElement.v
isibleBoundsInVisualViewport(), ownerElement.document().view()); |
| 250 | 250 |
| 251 PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><styl
e>\n", data); | 251 PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><styl
e>\n", data); |
| 252 data->append(Platform::current()->loadResource("pickerCommon.css")); | 252 data->append(Platform::current()->loadResource("pickerCommon.css")); |
| 253 data->append(Platform::current()->loadResource("listPicker.css")); | 253 data->append(Platform::current()->loadResource("listPicker.css")); |
| 254 PagePopupClient::addString("</style></head><body><div id=main>Loading...</di
v><script>\n" | 254 PagePopupClient::addString("</style></head><body><div id=main>Loading...</di
v><script>\n" |
| 255 "window.dialogArguments = {\n", data); | 255 "window.dialogArguments = {\n", data); |
| 256 addProperty("selectedIndex", ownerElement.selectedListIndex(), data); | 256 addProperty("selectedIndex", ownerElement.selectedListIndex(), data); |
| 257 const ComputedStyle* ownerStyle = ownerElement.computedStyle(); | 257 const ComputedStyle* ownerStyle = ownerElement.computedStyle(); |
| 258 ItemIterationContext context(*ownerStyle, data); | 258 ItemIterationContext context(*ownerStyle, data); |
| 259 context.serializeBaseStyle(); | 259 context.serializeBaseStyle(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 context.finishGroupIfNecessary(); | 504 context.finishGroupIfNecessary(); |
| 505 if (isHTMLOptionElement(child)) | 505 if (isHTMLOptionElement(child)) |
| 506 addOption(context, toHTMLOptionElement(child)); | 506 addOption(context, toHTMLOptionElement(child)); |
| 507 else if (isHTMLOptGroupElement(child)) | 507 else if (isHTMLOptGroupElement(child)) |
| 508 addOptGroup(context, toHTMLOptGroupElement(child)); | 508 addOptGroup(context, toHTMLOptGroupElement(child)); |
| 509 else if (isHTMLHRElement(child)) | 509 else if (isHTMLHRElement(child)) |
| 510 addSeparator(context, toHTMLHRElement(child)); | 510 addSeparator(context, toHTMLHRElement(child)); |
| 511 } | 511 } |
| 512 context.finishGroupIfNecessary(); | 512 context.finishGroupIfNecessary(); |
| 513 PagePopupClient::addString("],\n", data.get()); | 513 PagePopupClient::addString("],\n", data.get()); |
| 514 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(m_ownerElement
->elementRectRelativeToViewport(), ownerElement().document().view()); | 514 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(m_ownerElement
->visibleBoundsInVisualViewport(), ownerElement().document().view()); |
| 515 addProperty("anchorRectInScreen", anchorRectInScreen, data.get()); | 515 addProperty("anchorRectInScreen", anchorRectInScreen, data.get()); |
| 516 PagePopupClient::addString("}\n", data.get()); | 516 PagePopupClient::addString("}\n", data.get()); |
| 517 m_popup->postMessage(String::fromUTF8(data->data(), data->size())); | 517 m_popup->postMessage(String::fromUTF8(data->data(), data->size())); |
| 518 } | 518 } |
| 519 | 519 |
| 520 | 520 |
| 521 void PopupMenuImpl::disconnectClient() | 521 void PopupMenuImpl::disconnectClient() |
| 522 { | 522 { |
| 523 m_ownerElement = nullptr; | 523 m_ownerElement = nullptr; |
| 524 // Cannot be done during finalization, so instead done when the | 524 // Cannot be done during finalization, so instead done when the |
| 525 // layout object is destroyed and disconnected. | 525 // layout object is destroyed and disconnected. |
| 526 dispose(); | 526 dispose(); |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace blink | 529 } // namespace blink |
| OLD | NEW |