OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. | 2 * Copyright (C) 2007 Apple Inc. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2008 Collabora Ltd. | 4 * Copyright (C) 2008 Collabora Ltd. |
5 * Copyright (C) 2008, 2009 Google Inc. | 5 * Copyright (C) 2008, 2009 Google Inc. |
6 * Copyright (C) 2009 Kenneth Rohde Christiansen | 6 * Copyright (C) 2009 Kenneth Rohde Christiansen |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 bool LayoutThemeDefault::paintMenuList(LayoutObject* o, const PaintInfo& i, cons
t IntRect& rect) | 341 bool LayoutThemeDefault::paintMenuList(LayoutObject* o, const PaintInfo& i, cons
t IntRect& rect) |
342 { | 342 { |
343 if (!o->isBox()) | 343 if (!o->isBox()) |
344 return false; | 344 return false; |
345 | 345 |
346 const int right = rect.x() + rect.width(); | 346 const int right = rect.x() + rect.width(); |
347 const int middle = rect.y() + rect.height() / 2; | 347 const int middle = rect.y() + rect.height() / 2; |
348 | 348 |
349 WebThemeEngine::ExtraParams extraParams; | 349 WebThemeEngine::ExtraParams extraParams; |
350 extraParams.menuList.arrowY = middle; | 350 extraParams.menuList.arrowY = middle; |
351 const RenderBox* box = toRenderBox(o); | 351 const LayoutBox* box = toLayoutBox(o); |
352 // Match Chromium Win behaviour of showing all borders if any are shown. | 352 // Match Chromium Win behaviour of showing all borders if any are shown. |
353 extraParams.menuList.hasBorder = box->borderRight() || box->borderLeft() ||
box->borderTop() || box->borderBottom(); | 353 extraParams.menuList.hasBorder = box->borderRight() || box->borderLeft() ||
box->borderTop() || box->borderBottom(); |
354 extraParams.menuList.hasBorderRadius = o->style()->hasBorderRadius(); | 354 extraParams.menuList.hasBorderRadius = o->style()->hasBorderRadius(); |
355 // Fallback to transparent if the specified color object is invalid. | 355 // Fallback to transparent if the specified color object is invalid. |
356 Color backgroundColor(Color::transparent); | 356 Color backgroundColor(Color::transparent); |
357 if (o->hasBackground()) | 357 if (o->hasBackground()) |
358 backgroundColor = o->resolveColor(CSSPropertyBackgroundColor); | 358 backgroundColor = o->resolveColor(CSSPropertyBackgroundColor); |
359 extraParams.menuList.backgroundColor = backgroundColor.rgb(); | 359 extraParams.menuList.backgroundColor = backgroundColor.rgb(); |
360 | 360 |
361 // If we have a background image, don't fill the content area to expose the | 361 // If we have a background image, don't fill the content area to expose the |
(...skipping 30 matching lines...) Expand all Loading... |
392 const int middle = rect.y() + rect.height() / 2; | 392 const int middle = rect.y() + rect.height() / 2; |
393 | 393 |
394 WebThemeEngine::ExtraParams extraParams; | 394 WebThemeEngine::ExtraParams extraParams; |
395 extraParams.menuList.arrowY = middle; | 395 extraParams.menuList.arrowY = middle; |
396 extraParams.menuList.hasBorder = false; | 396 extraParams.menuList.hasBorder = false; |
397 extraParams.menuList.hasBorderRadius = o->style()->hasBorderRadius(); | 397 extraParams.menuList.hasBorderRadius = o->style()->hasBorderRadius(); |
398 extraParams.menuList.backgroundColor = Color::transparent; | 398 extraParams.menuList.backgroundColor = Color::transparent; |
399 extraParams.menuList.fillContentArea = false; | 399 extraParams.menuList.fillContentArea = false; |
400 | 400 |
401 if (useMockTheme()) { | 401 if (useMockTheme()) { |
402 const RenderBox* box = toRenderBox(o); | 402 const LayoutBox* box = toLayoutBox(o); |
403 // The size and position of the drop-down button is different between | 403 // The size and position of the drop-down button is different between |
404 // the mock theme and the regular aura theme. | 404 // the mock theme and the regular aura theme. |
405 int spacingTop = box->borderTop() + box->paddingTop(); | 405 int spacingTop = box->borderTop() + box->paddingTop(); |
406 int spacingBottom = box->borderBottom() + box->paddingBottom(); | 406 int spacingBottom = box->borderBottom() + box->paddingBottom(); |
407 int spacingRight = box->borderRight() + box->paddingRight(); | 407 int spacingRight = box->borderRight() + box->paddingRight(); |
408 extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x(
) + 4 + spacingRight: right - 13 - spacingRight; | 408 extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x(
) + 4 + spacingRight: right - 13 - spacingRight; |
409 extraParams.menuList.arrowHeight = rect.height() - spacingBottom - spaci
ngTop; | 409 extraParams.menuList.arrowHeight = rect.height() - spacingBottom - spaci
ngTop; |
410 } else { | 410 } else { |
411 extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x(
) + 7 : right - 13; | 411 extraParams.menuList.arrowX = (o->style()->direction() == RTL) ? rect.x(
) + 7 : right - 13; |
412 } | 412 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 | 613 |
614 bool LayoutThemeDefault::paintSearchFieldCancelButton(LayoutObject* cancelButton
Object, const PaintInfo& paintInfo, const IntRect& r) | 614 bool LayoutThemeDefault::paintSearchFieldCancelButton(LayoutObject* cancelButton
Object, const PaintInfo& paintInfo, const IntRect& r) |
615 { | 615 { |
616 // Get the renderer of <input> element. | 616 // Get the renderer of <input> element. |
617 if (!cancelButtonObject->node()) | 617 if (!cancelButtonObject->node()) |
618 return false; | 618 return false; |
619 Node* input = cancelButtonObject->node()->shadowHost(); | 619 Node* input = cancelButtonObject->node()->shadowHost(); |
620 LayoutObject* baseRenderer = input ? input->renderer() : cancelButtonObject; | 620 LayoutObject* baseRenderer = input ? input->renderer() : cancelButtonObject; |
621 if (!baseRenderer->isBox()) | 621 if (!baseRenderer->isBox()) |
622 return false; | 622 return false; |
623 RenderBox* inputRenderBox = toRenderBox(baseRenderer); | 623 LayoutBox* inputLayoutBox = toLayoutBox(baseRenderer); |
624 LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); | 624 LayoutRect inputContentBox = inputLayoutBox->contentBoxRect(); |
625 | 625 |
626 // Make sure the scaled button stays square and will fit in its parent's box
. | 626 // Make sure the scaled button stays square and will fit in its parent's box
. |
627 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<Lay
outUnit>(inputContentBox.height(), r.height())); | 627 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<Lay
outUnit>(inputContentBox.height(), r.height())); |
628 // Calculate cancel button's coordinates relative to the input element. | 628 // Calculate cancel button's coordinates relative to the input element. |
629 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will | 629 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will |
630 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. | 630 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. |
631 LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(
inputRenderBox).width(), | 631 LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(
inputLayoutBox).width(), |
632 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1)
/ 2, | 632 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1)
/ 2, |
633 cancelButtonSize, cancelButtonSize); | 633 cancelButtonSize, cancelButtonSize); |
634 IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObj
ect, cancelButtonRect, r); | 634 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj
ect, cancelButtonRect, r); |
635 | 635 |
636 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); | 636 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); |
637 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); | 637 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); |
638 paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedIm
age : cancelImage, paintingRect); | 638 paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedIm
age : cancelImage, paintingRect); |
639 return false; | 639 return false; |
640 } | 640 } |
641 | 641 |
642 void LayoutThemeDefault::adjustSearchFieldDecorationStyle(LayoutStyle& style, El
ement*) const | 642 void LayoutThemeDefault::adjustSearchFieldDecorationStyle(LayoutStyle& style, El
ement*) const |
643 { | 643 { |
644 IntSize emptySize(1, 11); | 644 IntSize emptySize(1, 11); |
(...skipping 13 matching lines...) Expand all Loading... |
658 | 658 |
659 bool LayoutThemeDefault::paintSearchFieldResultsDecoration(LayoutObject* magnifi
erObject, const PaintInfo& paintInfo, const IntRect& r) | 659 bool LayoutThemeDefault::paintSearchFieldResultsDecoration(LayoutObject* magnifi
erObject, const PaintInfo& paintInfo, const IntRect& r) |
660 { | 660 { |
661 // Get the renderer of <input> element. | 661 // Get the renderer of <input> element. |
662 if (!magnifierObject->node()) | 662 if (!magnifierObject->node()) |
663 return false; | 663 return false; |
664 Node* input = magnifierObject->node()->shadowHost(); | 664 Node* input = magnifierObject->node()->shadowHost(); |
665 LayoutObject* baseRenderer = input ? input->renderer() : magnifierObject; | 665 LayoutObject* baseRenderer = input ? input->renderer() : magnifierObject; |
666 if (!baseRenderer->isBox()) | 666 if (!baseRenderer->isBox()) |
667 return false; | 667 return false; |
668 RenderBox* inputRenderBox = toRenderBox(baseRenderer); | 668 LayoutBox* inputLayoutBox = toLayoutBox(baseRenderer); |
669 LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); | 669 LayoutRect inputContentBox = inputLayoutBox->contentBoxRect(); |
670 | 670 |
671 // Make sure the scaled decoration stays square and will fit in its parent's
box. | 671 // Make sure the scaled decoration stays square and will fit in its parent's
box. |
672 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<Layout
Unit>(inputContentBox.height(), r.height())); | 672 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<Layout
Unit>(inputContentBox.height(), r.height())); |
673 // Calculate decoration's coordinates relative to the input element. | 673 // Calculate decoration's coordinates relative to the input element. |
674 // Center the decoration vertically. Round up though, so if it has to be on
e pixel off-center, it will | 674 // Center the decoration vertically. Round up though, so if it has to be on
e pixel off-center, it will |
675 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. | 675 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. |
676 LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputR
enderBox).width(), | 676 LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputL
ayoutBox).width(), |
677 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2
, | 677 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2
, |
678 magnifierSize, magnifierSize); | 678 magnifierSize, magnifierSize); |
679 IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject
, magnifierRect, r); | 679 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, magnifierObject
, magnifierRect, r); |
680 | 680 |
681 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc
hMagnifier"))); | 681 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc
hMagnifier"))); |
682 paintInfo.context->drawImage(magnifierImage, paintingRect); | 682 paintInfo.context->drawImage(magnifierImage, paintingRect); |
683 return false; | 683 return false; |
684 } | 684 } |
685 | 685 |
686 bool LayoutThemeDefault::paintMediaSliderTrack(LayoutObject* object, const Paint
Info& paintInfo, const IntRect& rect) | 686 bool LayoutThemeDefault::paintMediaSliderTrack(LayoutObject* object, const Paint
Info& paintInfo, const IntRect& rect) |
687 { | 687 { |
688 return LayoutMediaControls::paintMediaControlsPart(MediaSlider, object, pain
tInfo, rect); | 688 return LayoutMediaControls::paintMediaControlsPart(MediaSlider, object, pain
tInfo, rect); |
689 } | 689 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 } | 862 } |
863 | 863 |
864 LayoutThemeDefault::DirectionFlippingScope::~DirectionFlippingScope() | 864 LayoutThemeDefault::DirectionFlippingScope::~DirectionFlippingScope() |
865 { | 865 { |
866 if (!m_needsFlipping) | 866 if (!m_needsFlipping) |
867 return; | 867 return; |
868 m_paintInfo.context->restore(); | 868 m_paintInfo.context->restore(); |
869 } | 869 } |
870 | 870 |
871 } // namespace blink | 871 } // namespace blink |
OLD | NEW |