| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 DEFINE_TRACE(PopupMenuImpl) | 254 DEFINE_TRACE(PopupMenuImpl) |
| 255 { | 255 { |
| 256 visitor->trace(m_chromeClient); | 256 visitor->trace(m_chromeClient); |
| 257 visitor->trace(m_ownerElement); | 257 visitor->trace(m_ownerElement); |
| 258 PopupMenu::trace(visitor); | 258 PopupMenu::trace(visitor); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void PopupMenuImpl::writeDocument(SharedBuffer* data) | 261 void PopupMenuImpl::writeDocument(SharedBuffer* data) |
| 262 { | 262 { |
| 263 HTMLSelectElement& ownerElement = *m_ownerElement; | 263 HTMLSelectElement& ownerElement = *m_ownerElement; |
| 264 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(ownerElement.e
lementRectRelativeToViewport()); | 264 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(ownerElement.e
lementRectRelativeToViewport(), ownerElement.document().view()); |
| 265 | 265 |
| 266 PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><styl
e>\n", data); | 266 PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><styl
e>\n", data); |
| 267 data->append(Platform::current()->loadResource("pickerCommon.css")); | 267 data->append(Platform::current()->loadResource("pickerCommon.css")); |
| 268 data->append(Platform::current()->loadResource("listPicker.css")); | 268 data->append(Platform::current()->loadResource("listPicker.css")); |
| 269 PagePopupClient::addString("</style></head><body><div id=main>Loading...</di
v><script>\n" | 269 PagePopupClient::addString("</style></head><body><div id=main>Loading...</di
v><script>\n" |
| 270 "window.dialogArguments = {\n", data); | 270 "window.dialogArguments = {\n", data); |
| 271 addProperty("selectedIndex", ownerElement.optionToListIndex(ownerElement.sel
ectedIndex()), data); | 271 addProperty("selectedIndex", ownerElement.optionToListIndex(ownerElement.sel
ectedIndex()), data); |
| 272 const ComputedStyle* ownerStyle = ownerElement.computedStyle(); | 272 const ComputedStyle* ownerStyle = ownerElement.computedStyle(); |
| 273 ItemIterationContext context(*ownerStyle, data); | 273 ItemIterationContext context(*ownerStyle, data); |
| 274 context.serializeBaseStyle(); | 274 context.serializeBaseStyle(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 context.finishGroupIfNecessary(); | 519 context.finishGroupIfNecessary(); |
| 520 if (isHTMLOptionElement(child)) | 520 if (isHTMLOptionElement(child)) |
| 521 addOption(context, toHTMLOptionElement(child)); | 521 addOption(context, toHTMLOptionElement(child)); |
| 522 else if (isHTMLOptGroupElement(child)) | 522 else if (isHTMLOptGroupElement(child)) |
| 523 addOptGroup(context, toHTMLOptGroupElement(child)); | 523 addOptGroup(context, toHTMLOptGroupElement(child)); |
| 524 else if (isHTMLHRElement(child)) | 524 else if (isHTMLHRElement(child)) |
| 525 addSeparator(context, toHTMLHRElement(child)); | 525 addSeparator(context, toHTMLHRElement(child)); |
| 526 } | 526 } |
| 527 context.finishGroupIfNecessary(); | 527 context.finishGroupIfNecessary(); |
| 528 PagePopupClient::addString("],\n", data.get()); | 528 PagePopupClient::addString("],\n", data.get()); |
| 529 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(m_ownerElement
->elementRectRelativeToViewport()); | 529 IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(m_ownerElement
->elementRectRelativeToViewport(), ownerElement().document().view()); |
| 530 addProperty("anchorRectInScreen", anchorRectInScreen, data.get()); | 530 addProperty("anchorRectInScreen", anchorRectInScreen, data.get()); |
| 531 PagePopupClient::addString("}\n", data.get()); | 531 PagePopupClient::addString("}\n", data.get()); |
| 532 m_popup->postMessage(String::fromUTF8(data->data(), data->size())); | 532 m_popup->postMessage(String::fromUTF8(data->data(), data->size())); |
| 533 } | 533 } |
| 534 | 534 |
| 535 | 535 |
| 536 void PopupMenuImpl::disconnectClient() | 536 void PopupMenuImpl::disconnectClient() |
| 537 { | 537 { |
| 538 m_ownerElement = nullptr; | 538 m_ownerElement = nullptr; |
| 539 // Cannot be done during finalization, so instead done when the | 539 // Cannot be done during finalization, so instead done when the |
| 540 // layout object is destroyed and disconnected. | 540 // layout object is destroyed and disconnected. |
| 541 dispose(); | 541 dispose(); |
| 542 } | 542 } |
| 543 | 543 |
| 544 } // namespace blink | 544 } // namespace blink |
| OLD | NEW |