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/NodeComputedStyle.h" | 10 #include "core/dom/NodeComputedStyle.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 DEFINE_TRACE(PopupMenuImpl) { | 255 DEFINE_TRACE(PopupMenuImpl) { |
256 visitor->Trace(chrome_client_); | 256 visitor->Trace(chrome_client_); |
257 visitor->Trace(owner_element_); | 257 visitor->Trace(owner_element_); |
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 HTMLSelectElement& owner_element = *owner_element_; | 262 HTMLSelectElement& owner_element = *owner_element_; |
263 IntRect anchor_rect_in_screen = chrome_client_->ViewportToScreen( | 263 IntRect anchor_rect_in_screen = chrome_client_->ViewportToScreen( |
264 owner_element.VisibleBoundsInVisualViewport(), | 264 owner_element.VisibleBoundsInVisualViewport(), |
265 owner_element.GetDocument().View()); | 265 owner_element.GetDocument().GetFrame()); |
266 | 266 |
267 float scale_factor = chrome_client_->WindowToViewportScalar(1.f); | 267 float scale_factor = chrome_client_->WindowToViewportScalar(1.f); |
268 PagePopupClient::AddString( | 268 PagePopupClient::AddString( |
269 "<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data); | 269 "<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data); |
270 data->Append(Platform::Current()->LoadResource("pickerCommon.css")); | 270 data->Append(Platform::Current()->LoadResource("pickerCommon.css")); |
271 data->Append(Platform::Current()->LoadResource("listPicker.css")); | 271 data->Append(Platform::Current()->LoadResource("listPicker.css")); |
272 if (!RuntimeEnabledFeatures::forceTallerSelectPopupEnabled()) | 272 if (!RuntimeEnabledFeatures::forceTallerSelectPopupEnabled()) |
273 PagePopupClient::AddString("@media (any-pointer:coarse) {", data); | 273 PagePopupClient::AddString("@media (any-pointer:coarse) {", data); |
274 int padding = static_cast<int>(roundf(4 * scale_factor)); | 274 int padding = static_cast<int>(roundf(4 * scale_factor)); |
275 int min_height = static_cast<int>(roundf(24 * scale_factor)); | 275 int min_height = static_cast<int>(roundf(24 * scale_factor)); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 AddOption(context, toHTMLOptionElement(child)); | 565 AddOption(context, toHTMLOptionElement(child)); |
566 else if (isHTMLOptGroupElement(child)) | 566 else if (isHTMLOptGroupElement(child)) |
567 AddOptGroup(context, toHTMLOptGroupElement(child)); | 567 AddOptGroup(context, toHTMLOptGroupElement(child)); |
568 else if (isHTMLHRElement(child)) | 568 else if (isHTMLHRElement(child)) |
569 AddSeparator(context, toHTMLHRElement(child)); | 569 AddSeparator(context, toHTMLHRElement(child)); |
570 } | 570 } |
571 context.FinishGroupIfNecessary(); | 571 context.FinishGroupIfNecessary(); |
572 PagePopupClient::AddString("],\n", data.Get()); | 572 PagePopupClient::AddString("],\n", data.Get()); |
573 IntRect anchor_rect_in_screen = chrome_client_->ViewportToScreen( | 573 IntRect anchor_rect_in_screen = chrome_client_->ViewportToScreen( |
574 owner_element_->VisibleBoundsInVisualViewport(), | 574 owner_element_->VisibleBoundsInVisualViewport(), |
575 OwnerElement().GetDocument().View()); | 575 OwnerElement().GetDocument().GetFrame()); |
576 AddProperty("anchorRectInScreen", anchor_rect_in_screen, data.Get()); | 576 AddProperty("anchorRectInScreen", anchor_rect_in_screen, data.Get()); |
577 PagePopupClient::AddString("}\n", data.Get()); | 577 PagePopupClient::AddString("}\n", data.Get()); |
578 popup_->PostMessage(String::FromUTF8(data->Data(), data->size())); | 578 popup_->PostMessage(String::FromUTF8(data->Data(), data->size())); |
579 } | 579 } |
580 | 580 |
581 void PopupMenuImpl::DisconnectClient() { | 581 void PopupMenuImpl::DisconnectClient() { |
582 owner_element_ = nullptr; | 582 owner_element_ = nullptr; |
583 // Cannot be done during finalization, so instead done when the | 583 // Cannot be done during finalization, so instead done when the |
584 // layout object is destroyed and disconnected. | 584 // layout object is destroyed and disconnected. |
585 Dispose(); | 585 Dispose(); |
586 } | 586 } |
587 | 587 |
588 } // namespace blink | 588 } // namespace blink |
OLD | NEW |