| 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 "config.h" | 5 #include "config.h" |
| 6 #include "web/PopupMenuImpl.h" | 6 #include "web/PopupMenuImpl.h" |
| 7 | 7 |
| 8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 9 #include "core/css/CSSFontSelector.h" | 9 #include "core/css/CSSFontSelector.h" |
| 10 #include "core/dom/ElementTraversal.h" | 10 #include "core/dom/ElementTraversal.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 #endif | 181 #endif |
| 182 } | 182 } |
| 183 | 183 |
| 184 void serializeBaseStyle() | 184 void serializeBaseStyle() |
| 185 { | 185 { |
| 186 ASSERT(!m_isInGroup); | 186 ASSERT(!m_isInGroup); |
| 187 PagePopupClient::addString("baseStyle: {", m_buffer); | 187 PagePopupClient::addString("baseStyle: {", m_buffer); |
| 188 addProperty("backgroundColor", m_backgroundColor.serialized(), m_buffer)
; | 188 addProperty("backgroundColor", m_backgroundColor.serialized(), m_buffer)
; |
| 189 addProperty("color", baseStyle().visitedDependentColor(CSSPropertyColor)
.serialized(), m_buffer); | 189 addProperty("color", baseStyle().visitedDependentColor(CSSPropertyColor)
.serialized(), m_buffer); |
| 190 addProperty("textTransform", String(textTransformToString(baseStyle().te
xtTransform())), m_buffer); | 190 addProperty("textTransform", String(textTransformToString(baseStyle().te
xtTransform())), m_buffer); |
| 191 addProperty("fontSize", baseFont().computedPixelSize(), m_buffer); | 191 addProperty("fontSize", baseFont().specifiedSize(), m_buffer); |
| 192 addProperty("fontStyle", String(fontStyleToString(baseFont().style())),
m_buffer); | 192 addProperty("fontStyle", String(fontStyleToString(baseFont().style())),
m_buffer); |
| 193 addProperty("fontVariant", String(fontVariantToString(baseFont().variant
())), m_buffer); | 193 addProperty("fontVariant", String(fontVariantToString(baseFont().variant
())), m_buffer); |
| 194 | 194 |
| 195 PagePopupClient::addString("fontFamily: [", m_buffer); | 195 PagePopupClient::addString("fontFamily: [", m_buffer); |
| 196 for (const FontFamily* f = &baseFont().family(); f; f = f->next()) { | 196 for (const FontFamily* f = &baseFont().family(); f; f = f->next()) { |
| 197 addJavaScriptString(f->family().string(), m_buffer); | 197 addJavaScriptString(f->family().string(), m_buffer); |
| 198 if (f->next()) | 198 if (f->next()) |
| 199 PagePopupClient::addString(",", m_buffer); | 199 PagePopupClient::addString(",", m_buffer); |
| 200 } | 200 } |
| 201 PagePopupClient::addString("]", m_buffer); | 201 PagePopupClient::addString("]", m_buffer); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 if (isHTMLOptionElement(child)) | 282 if (isHTMLOptionElement(child)) |
| 283 addOption(context, toHTMLOptionElement(child)); | 283 addOption(context, toHTMLOptionElement(child)); |
| 284 else if (isHTMLOptGroupElement(child)) | 284 else if (isHTMLOptGroupElement(child)) |
| 285 addOptGroup(context, toHTMLOptGroupElement(child)); | 285 addOptGroup(context, toHTMLOptGroupElement(child)); |
| 286 else if (isHTMLHRElement(child)) | 286 else if (isHTMLHRElement(child)) |
| 287 addSeparator(context, toHTMLHRElement(child)); | 287 addSeparator(context, toHTMLHRElement(child)); |
| 288 } | 288 } |
| 289 context.finishGroupIfNecessary(); | 289 context.finishGroupIfNecessary(); |
| 290 PagePopupClient::addString("],\n", data); | 290 PagePopupClient::addString("],\n", data); |
| 291 | 291 |
| 292 float zoom = zoomFactor(); |
| 292 addProperty("anchorRectInScreen", anchorRectInScreen, data); | 293 addProperty("anchorRectInScreen", anchorRectInScreen, data); |
| 294 addProperty("zoomFactor", zoom, data); |
| 293 bool isRTL = !ownerStyle->isLeftToRightDirection(); | 295 bool isRTL = !ownerStyle->isLeftToRightDirection(); |
| 294 addProperty("isRTL", isRTL, data); | 296 addProperty("isRTL", isRTL, data); |
| 295 addProperty("paddingStart", isRTL ? ownerElement.clientPaddingRight().toDoub
le() : ownerElement.clientPaddingLeft().toDouble(), data); | 297 addProperty("paddingStart", isRTL ? ownerElement.clientPaddingRight().toDoub
le() / zoom : ownerElement.clientPaddingLeft().toDouble() / zoom, data); |
| 296 PagePopupClient::addString("};\n", data); | 298 PagePopupClient::addString("};\n", data); |
| 297 data->append(Platform::current()->loadResource("pickerCommon.js")); | 299 data->append(Platform::current()->loadResource("pickerCommon.js")); |
| 298 data->append(Platform::current()->loadResource("listPicker.js")); | 300 data->append(Platform::current()->loadResource("listPicker.js")); |
| 299 PagePopupClient::addString("</script></body>\n", data); | 301 PagePopupClient::addString("</script></body>\n", data); |
| 300 } | 302 } |
| 301 | 303 |
| 302 void PopupMenuImpl::addElementStyle(ItemIterationContext& context, HTMLElement&
element) | 304 void PopupMenuImpl::addElementStyle(ItemIterationContext& context, HTMLElement&
element) |
| 303 { | 305 { |
| 304 const ComputedStyle* style = m_ownerElement->itemComputedStyle(element); | 306 const ComputedStyle* style = m_ownerElement->itemComputedStyle(element); |
| 305 ASSERT(style); | 307 ASSERT(style); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 317 if (isOverride(style->unicodeBidi())) | 319 if (isOverride(style->unicodeBidi())) |
| 318 addProperty("unicodeBidi", String("bidi-override"), data); | 320 addProperty("unicodeBidi", String("bidi-override"), data); |
| 319 Color foregroundColor = style->visitedDependentColor(CSSPropertyColor); | 321 Color foregroundColor = style->visitedDependentColor(CSSPropertyColor); |
| 320 if (baseStyle.visitedDependentColor(CSSPropertyColor) != foregroundColor) | 322 if (baseStyle.visitedDependentColor(CSSPropertyColor) != foregroundColor) |
| 321 addProperty("color", foregroundColor.serialized(), data); | 323 addProperty("color", foregroundColor.serialized(), data); |
| 322 Color backgroundColor = style->visitedDependentColor(CSSPropertyBackgroundCo
lor); | 324 Color backgroundColor = style->visitedDependentColor(CSSPropertyBackgroundCo
lor); |
| 323 if (context.backgroundColor() != backgroundColor && backgroundColor != Color
::transparent) | 325 if (context.backgroundColor() != backgroundColor && backgroundColor != Color
::transparent) |
| 324 addProperty("backgroundColor", backgroundColor.serialized(), data); | 326 addProperty("backgroundColor", backgroundColor.serialized(), data); |
| 325 const FontDescription& baseFont = context.baseFont(); | 327 const FontDescription& baseFont = context.baseFont(); |
| 326 const FontDescription& fontDescription = style->font().fontDescription(); | 328 const FontDescription& fontDescription = style->font().fontDescription(); |
| 327 if (baseFont.computedPixelSize() != fontDescription.computedPixelSize()) | 329 if (baseFont.computedPixelSize() != fontDescription.computedPixelSize()) { |
| 328 addProperty("fontSize", fontDescription.computedPixelSize(), data); | 330 // We don't use FontDescription::specifiedSize() because this element |
| 331 // might have its own zoom level. |
| 332 addProperty("fontSize", fontDescription.computedSize() / zoomFactor(), d
ata); |
| 333 } |
| 329 // Our UA stylesheet has font-weight:normal for OPTION. | 334 // Our UA stylesheet has font-weight:normal for OPTION. |
| 330 if (FontWeightNormal != fontDescription.weight()) | 335 if (FontWeightNormal != fontDescription.weight()) |
| 331 addProperty("fontWeight", String(fontWeightToString(fontDescription.weig
ht())), data); | 336 addProperty("fontWeight", String(fontWeightToString(fontDescription.weig
ht())), data); |
| 332 if (baseFont.family() != fontDescription.family()) { | 337 if (baseFont.family() != fontDescription.family()) { |
| 333 PagePopupClient::addString("fontFamily: [\n", data); | 338 PagePopupClient::addString("fontFamily: [\n", data); |
| 334 for (const FontFamily* f = &fontDescription.family(); f; f = f->next())
{ | 339 for (const FontFamily* f = &fontDescription.family(); f; f = f->next())
{ |
| 335 addJavaScriptString(f->family().string(), data); | 340 addJavaScriptString(f->family().string(), data); |
| 336 if (f->next()) | 341 if (f->next()) |
| 337 PagePopupClient::addString(",\n", data); | 342 PagePopupClient::addString(",\n", data); |
| 338 } | 343 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 522 |
| 518 void PopupMenuImpl::disconnectClient() | 523 void PopupMenuImpl::disconnectClient() |
| 519 { | 524 { |
| 520 m_ownerElement = nullptr; | 525 m_ownerElement = nullptr; |
| 521 // Cannot be done during finalization, so instead done when the | 526 // Cannot be done during finalization, so instead done when the |
| 522 // layout object is destroyed and disconnected. | 527 // layout object is destroyed and disconnected. |
| 523 dispose(); | 528 dispose(); |
| 524 } | 529 } |
| 525 | 530 |
| 526 } // namespace blink | 531 } // namespace blink |
| OLD | NEW |