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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 DCHECK(!m_isInGroup); | 170 DCHECK(!m_isInGroup); |
171 PagePopupClient::addString("baseStyle: {", m_buffer); | 171 PagePopupClient::addString("baseStyle: {", m_buffer); |
172 addProperty("backgroundColor", m_backgroundColor.serialized(), m_buffer); | 172 addProperty("backgroundColor", m_backgroundColor.serialized(), m_buffer); |
173 addProperty( | 173 addProperty( |
174 "color", | 174 "color", |
175 baseStyle().visitedDependentColor(CSSPropertyColor).serialized(), | 175 baseStyle().visitedDependentColor(CSSPropertyColor).serialized(), |
176 m_buffer); | 176 m_buffer); |
177 addProperty("textTransform", | 177 addProperty("textTransform", |
178 String(textTransformToString(baseStyle().textTransform())), | 178 String(textTransformToString(baseStyle().textTransform())), |
179 m_buffer); | 179 m_buffer); |
180 addProperty("fontSize", baseFont().specifiedSize(), m_buffer); | 180 addProperty("fontSize", baseFont().computedPixelSize(), m_buffer); |
181 addProperty("fontStyle", String(fontStyleToString(baseFont().style())), | 181 addProperty("fontStyle", String(fontStyleToString(baseFont().style())), |
182 m_buffer); | 182 m_buffer); |
183 addProperty("fontVariant", | 183 addProperty("fontVariant", |
184 baseFont().variantCaps() == FontDescription::SmallCaps | 184 baseFont().variantCaps() == FontDescription::SmallCaps |
185 ? String("small-caps") | 185 ? String("small-caps") |
186 : String(), | 186 : String(), |
187 m_buffer); | 187 m_buffer); |
188 | 188 |
189 PagePopupClient::addString("fontFamily: [", m_buffer); | 189 PagePopupClient::addString("fontFamily: [", m_buffer); |
190 for (const FontFamily* f = &baseFont().family(); f; f = f->next()) { | 190 for (const FontFamily* f = &baseFont().family(); f; f = f->next()) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 addOption(context, toHTMLOptionElement(child)); | 285 addOption(context, toHTMLOptionElement(child)); |
286 else if (isHTMLOptGroupElement(child)) | 286 else if (isHTMLOptGroupElement(child)) |
287 addOptGroup(context, toHTMLOptGroupElement(child)); | 287 addOptGroup(context, toHTMLOptGroupElement(child)); |
288 else if (isHTMLHRElement(child)) | 288 else if (isHTMLHRElement(child)) |
289 addSeparator(context, toHTMLHRElement(child)); | 289 addSeparator(context, toHTMLHRElement(child)); |
290 } | 290 } |
291 context.finishGroupIfNecessary(); | 291 context.finishGroupIfNecessary(); |
292 PagePopupClient::addString("],\n", data); | 292 PagePopupClient::addString("],\n", data); |
293 | 293 |
294 addProperty("anchorRectInScreen", anchorRectInScreen, data); | 294 addProperty("anchorRectInScreen", anchorRectInScreen, data); |
295 float zoom = zoomFactor(); | |
296 float scaleFactor = m_chromeClient->windowToViewportScalar(1.f); | 295 float scaleFactor = m_chromeClient->windowToViewportScalar(1.f); |
297 addProperty("zoomFactor", zoom / scaleFactor, data); | 296 addProperty("zoomFactor", 1, data); |
| 297 addProperty("scaleFactor", scaleFactor, data); |
298 bool isRTL = !ownerStyle->isLeftToRightDirection(); | 298 bool isRTL = !ownerStyle->isLeftToRightDirection(); |
299 addProperty("isRTL", isRTL, data); | 299 addProperty("isRTL", isRTL, data); |
300 addProperty("paddingStart", | 300 addProperty("paddingStart", |
301 isRTL ? ownerElement.clientPaddingRight().toDouble() / zoom | 301 isRTL ? ownerElement.clientPaddingRight().toDouble() |
302 : ownerElement.clientPaddingLeft().toDouble() / zoom, | 302 : ownerElement.clientPaddingLeft().toDouble(), |
303 data); | 303 data); |
304 PagePopupClient::addString("};\n", data); | 304 PagePopupClient::addString("};\n", data); |
305 data->append(Platform::current()->loadResource("pickerCommon.js")); | 305 data->append(Platform::current()->loadResource("pickerCommon.js")); |
306 data->append(Platform::current()->loadResource("listPicker.js")); | 306 data->append(Platform::current()->loadResource("listPicker.js")); |
307 PagePopupClient::addString("</script></body>\n", data); | 307 PagePopupClient::addString("</script></body>\n", data); |
308 } | 308 } |
309 | 309 |
310 void PopupMenuImpl::addElementStyle(ItemIterationContext& context, | 310 void PopupMenuImpl::addElementStyle(ItemIterationContext& context, |
311 HTMLElement& element) { | 311 HTMLElement& element) { |
312 const ComputedStyle* style = m_ownerElement->itemComputedStyle(element); | 312 const ComputedStyle* style = m_ownerElement->itemComputedStyle(element); |
(...skipping 20 matching lines...) Expand all Loading... |
333 Color backgroundColor = | 333 Color backgroundColor = |
334 style->visitedDependentColor(CSSPropertyBackgroundColor); | 334 style->visitedDependentColor(CSSPropertyBackgroundColor); |
335 if (context.backgroundColor() != backgroundColor && | 335 if (context.backgroundColor() != backgroundColor && |
336 backgroundColor != Color::transparent) | 336 backgroundColor != Color::transparent) |
337 addProperty("backgroundColor", backgroundColor.serialized(), data); | 337 addProperty("backgroundColor", backgroundColor.serialized(), data); |
338 const FontDescription& baseFont = context.baseFont(); | 338 const FontDescription& baseFont = context.baseFont(); |
339 const FontDescription& fontDescription = style->font().getFontDescription(); | 339 const FontDescription& fontDescription = style->font().getFontDescription(); |
340 if (baseFont.computedPixelSize() != fontDescription.computedPixelSize()) { | 340 if (baseFont.computedPixelSize() != fontDescription.computedPixelSize()) { |
341 // We don't use FontDescription::specifiedSize() because this element | 341 // We don't use FontDescription::specifiedSize() because this element |
342 // might have its own zoom level. | 342 // might have its own zoom level. |
343 addProperty("fontSize", fontDescription.computedSize() / zoomFactor(), | 343 addProperty("fontSize", fontDescription.computedPixelSize(), data); |
344 data); | |
345 } | 344 } |
346 // Our UA stylesheet has font-weight:normal for OPTION. | 345 // Our UA stylesheet has font-weight:normal for OPTION. |
347 if (FontWeightNormal != fontDescription.weight()) | 346 if (FontWeightNormal != fontDescription.weight()) |
348 addProperty("fontWeight", | 347 addProperty("fontWeight", |
349 String(fontWeightToString(fontDescription.weight())), data); | 348 String(fontWeightToString(fontDescription.weight())), data); |
350 if (baseFont.family() != fontDescription.family()) { | 349 if (baseFont.family() != fontDescription.family()) { |
351 PagePopupClient::addString("fontFamily: [\n", data); | 350 PagePopupClient::addString("fontFamily: [\n", data); |
352 for (const FontFamily* f = &fontDescription.family(); f; f = f->next()) { | 351 for (const FontFamily* f = &fontDescription.family(); f; f = f->next()) { |
353 addJavaScriptString(f->family().getString(), data); | 352 addJavaScriptString(f->family().getString(), data); |
354 if (f->next()) | 353 if (f->next()) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 553 } |
555 | 554 |
556 void PopupMenuImpl::disconnectClient() { | 555 void PopupMenuImpl::disconnectClient() { |
557 m_ownerElement = nullptr; | 556 m_ownerElement = nullptr; |
558 // Cannot be done during finalization, so instead done when the | 557 // Cannot be done during finalization, so instead done when the |
559 // layout object is destroyed and disconnected. | 558 // layout object is destroyed and disconnected. |
560 dispose(); | 559 dispose(); |
561 } | 560 } |
562 | 561 |
563 } // namespace blink | 562 } // namespace blink |
OLD | NEW |