Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: third_party/WebKit/WebCore/rendering/RenderThemeChromiumWin.cpp

Issue 21201: Transparency (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * This file is part of the WebKit project. 2 * This file is part of the WebKit project.
3 * 3 *
4 * Copyright (C) 2006 Apple Computer, Inc. 4 * Copyright (C) 2006 Apple Computer, Inc.
5 * Copyright (C) 2008, 2009 Google, Inc. 5 * Copyright (C) 2008, 2009 Google, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 20 matching lines...) Expand all
31 #include "ChromiumBridge.h" 31 #include "ChromiumBridge.h"
32 #include "CSSStyleSheet.h" 32 #include "CSSStyleSheet.h"
33 #include "CSSValueKeywords.h" 33 #include "CSSValueKeywords.h"
34 #include "Document.h" 34 #include "Document.h"
35 #include "FontSelector.h" 35 #include "FontSelector.h"
36 #include "FontUtilsChromiumWin.h" 36 #include "FontUtilsChromiumWin.h"
37 #include "GraphicsContext.h" 37 #include "GraphicsContext.h"
38 #include "RenderBox.h" 38 #include "RenderBox.h"
39 #include "ScrollbarTheme.h" 39 #include "ScrollbarTheme.h"
40 #include "SkiaUtils.h" 40 #include "SkiaUtils.h"
41 #include "ThemeHelperChromiumWin.h" 41 #include "TransparencyWin.h"
42 #include "UserAgentStyleSheets.h" 42 #include "UserAgentStyleSheets.h"
43 #include "WindowsVersion.h" 43 #include "WindowsVersion.h"
44 44
45 // FIXME: This dependency should eventually be removed. 45 // FIXME: This dependency should eventually be removed.
46 #include <skia/ext/skia_utils_win.h> 46 #include <skia/ext/skia_utils_win.h>
47 47
48 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(structName, member) \ 48 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(structName, member) \
49 offsetof(structName, member) + \ 49 offsetof(structName, member) + \
50 (sizeof static_cast<structName*>(0)->member) 50 (sizeof static_cast<structName*>(0)->member)
51 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ 51 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \
52 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) 52 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont)
53 53
54 namespace WebCore { 54 namespace WebCore {
55 55
56 namespace {
57
58 bool canvasHasMultipleLayers(const SkCanvas* canvas)
59 {
60 SkCanvas::LayerIter iter(const_cast<SkCanvas*>(canvas), false);
61 iter.next(); // There is always at least one layer.
62 return !iter.done(); // There is > 1 layer if the the iterator can stil adv ance.
63 }
64
65 class ThemePainter : public TransparencyWin {
66 public:
67 ThemePainter(GraphicsContext* context, const IntRect& r) {
68 // Compute the transform mode.
69 TransformMode transformMode;
70 const TransformationMatrix& matrix = context->getCTM();
71 if (matrix.b() != 0 || matrix.c() != 0) // Skew.
72 transformMode = Untransform;
73 else if (matrix.a() != 1.0 || matrix.d() != 1.0) // Scale.
74 transformMode = ScaleTransform;
75 else // Nothing interesting.
76 transformMode = KeepTransform;
77
78 // Compute the layer mode.
79 LayerMode layerMode;
80 if (context->platformContext()->isDrawingToImageBuffer()) // Might have transparent background.
81 layerMode = WhiteLayer;
82 else if (canvasHasMultipleLayers(context->platformContext()->canvas())) // Needs antialiasing help.
83 layerMode = OpaqueCompositeLayer;
84 else // Nothing interesting.
85 layerMode = transformMode == KeepTransform ? NoLayer : OpaqueComposi teLayer;
86
87 init(context, layerMode, transformMode, r);
88 }
89 };
90
91 } // namespace
92
56 static void getNonClientMetrics(NONCLIENTMETRICS* metrics) { 93 static void getNonClientMetrics(NONCLIENTMETRICS* metrics) {
57 static UINT size = WebCore::isVistaOrNewer() ? 94 static UINT size = WebCore::isVistaOrNewer() ?
58 sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA; 95 sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA;
59 metrics->cbSize = size; 96 metrics->cbSize = size;
60 bool success = !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, size, metrics , 0); 97 bool success = !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, size, metrics , 0);
61 ASSERT(success); 98 ASSERT(success);
62 } 99 }
63 100
64 enum PaddingType { 101 enum PaddingType {
65 TopPadding, 102 TopPadding,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 void RenderThemeChromiumWin::setRadioSize(RenderStyle* style) const 403 void RenderThemeChromiumWin::setRadioSize(RenderStyle* style) const
367 { 404 {
368 // Use same sizing for radio box as checkbox. 405 // Use same sizing for radio box as checkbox.
369 setCheckboxSize(style); 406 setCheckboxSize(style);
370 } 407 }
371 408
372 bool RenderThemeChromiumWin::paintButton(RenderObject* o, const RenderObject::Pa intInfo& i, const IntRect& r) 409 bool RenderThemeChromiumWin::paintButton(RenderObject* o, const RenderObject::Pa intInfo& i, const IntRect& r)
373 { 410 {
374 const ThemeData& themeData = getThemeData(o); 411 const ThemeData& themeData = getThemeData(o);
375 412
376 WebCore::ThemeHelperWin helper(i.context, r); 413 WebCore::ThemePainter painter(i.context, r);
377 ChromiumBridge::paintButton(helper.context(), 414 ChromiumBridge::paintButton(painter.context(),
378 themeData.m_part, 415 themeData.m_part,
379 themeData.m_state, 416 themeData.m_state,
380 themeData.m_classicState, 417 themeData.m_classicState,
381 helper.rect()); 418 painter.drawRect());
382 return false; 419 return false;
383 } 420 }
384 421
385 bool RenderThemeChromiumWin::paintTextField(RenderObject* o, const RenderObject: :PaintInfo& i, const IntRect& r) 422 bool RenderThemeChromiumWin::paintTextField(RenderObject* o, const RenderObject: :PaintInfo& i, const IntRect& r)
386 { 423 {
387 return paintTextFieldInternal(o, i, r, true); 424 return paintTextFieldInternal(o, i, r, true);
388 } 425 }
389 426
390 bool RenderThemeChromiumWin::paintSearchField(RenderObject* o, const RenderObjec t::PaintInfo& i, const IntRect& r) 427 bool RenderThemeChromiumWin::paintSearchField(RenderObject* o, const RenderObjec t::PaintInfo& i, const IntRect& r)
391 { 428 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 else 471 else
435 buttonX = o->style()->direction() == LTR ? r.right() - spacingRight - bu ttonWidth : r.x() + spacingLeft; 472 buttonX = o->style()->direction() == LTR ? r.right() - spacingRight - bu ttonWidth : r.x() + spacingLeft;
436 473
437 // Compute the rectangle of the button in the destination image. 474 // Compute the rectangle of the button in the destination image.
438 IntRect rect(buttonX, 475 IntRect rect(buttonX,
439 r.y() + spacingTop, 476 r.y() + spacingTop,
440 std::min(buttonWidth, r.right() - r.x()), 477 std::min(buttonWidth, r.right() - r.x()),
441 r.height() - (spacingTop + spacingBottom)); 478 r.height() - (spacingTop + spacingBottom));
442 479
443 // Get the correct theme data for a textfield and paint the menu. 480 // Get the correct theme data for a textfield and paint the menu.
444 WebCore::ThemeHelperWin helper(i.context, rect); 481 WebCore::ThemePainter painter(i.context, rect);
445 ChromiumBridge::paintMenuList(helper.context(), 482 ChromiumBridge::paintMenuList(painter.context(),
446 CP_DROPDOWNBUTTON, 483 CP_DROPDOWNBUTTON,
447 determineState(o), 484 determineState(o),
448 determineClassicState(o), 485 determineClassicState(o),
449 helper.rect()); 486 painter.drawRect());
450 return false; 487 return false;
451 } 488 }
452 489
453 void RenderThemeChromiumWin::adjustMenuListButtonStyle(CSSStyleSelector* selecto r, RenderStyle* style, Element* e) const 490 void RenderThemeChromiumWin::adjustMenuListButtonStyle(CSSStyleSelector* selecto r, RenderStyle* style, Element* e) const
454 { 491 {
455 adjustMenuListStyle(selector, style, e); 492 adjustMenuListStyle(selector, style, e);
456 } 493 }
457 494
458 // Used to paint styled menulists (i.e. with a non-default border) 495 // Used to paint styled menulists (i.e. with a non-default border)
459 bool RenderThemeChromiumWin::paintMenuListButton(RenderObject* o, const RenderOb ject::PaintInfo& i, const IntRect& r) 496 bool RenderThemeChromiumWin::paintMenuListButton(RenderObject* o, const RenderOb ject::PaintInfo& i, const IntRect& r)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 break; 593 break;
557 } 594 }
558 595
559 result.m_state = determineState(o); 596 result.m_state = determineState(o);
560 result.m_classicState |= determineClassicState(o); 597 result.m_classicState |= determineClassicState(o);
561 598
562 return result; 599 return result;
563 } 600 }
564 601
565 bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o, 602 bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o,
566 const RenderObject::PaintInfo& i, 603 const RenderObject::PaintInf o& i,
567 const IntRect& r, 604 const IntRect& r,
568 bool drawEdges) 605 bool drawEdges)
569 { 606 {
570 // Nasty hack to make us not paint the border on text fields with a 607 // Nasty hack to make us not paint the border on text fields with a
571 // border-radius. Webkit paints elements with border-radius for us. 608 // border-radius. Webkit paints elements with border-radius for us.
572 // FIXME: Get rid of this if-check once we can properly clip rounded 609 // FIXME: Get rid of this if-check once we can properly clip rounded
573 // borders: http://b/1112604 and http://b/1108635 610 // borders: http://b/1112604 and http://b/1108635
574 // FIXME: make sure we do the right thing if css background-clip is set. 611 // FIXME: make sure we do the right thing if css background-clip is set.
575 if (o->style()->hasBorderRadius()) 612 if (o->style()->hasBorderRadius())
576 return false; 613 return false;
577 614
578 const ThemeData& themeData = getThemeData(o); 615 const ThemeData& themeData = getThemeData(o);
579 616
580 WebCore::ThemeHelperWin helper(i.context, r); 617 WebCore::ThemePainter painter(i.context, r);
581 ChromiumBridge::paintTextField(helper.context(), 618 ChromiumBridge::paintTextField(painter.context(),
582 themeData.m_part, 619 themeData.m_part,
583 themeData.m_state, 620 themeData.m_state,
584 themeData.m_classicState, 621 themeData.m_classicState,
585 helper.rect(), 622 painter.drawRect(),
586 o->style()->backgroundColor(), 623 o->style()->backgroundColor(),
587 true, 624 true,
588 drawEdges); 625 drawEdges);
589 return false; 626 return false;
590 } 627 }
591 628
592 int RenderThemeChromiumWin::menuListInternalPadding(RenderStyle* style, int padd ingType) const 629 int RenderThemeChromiumWin::menuListInternalPadding(RenderStyle* style, int padd ingType) const
593 { 630 {
594 // This internal padding is in addition to the user-supplied padding. 631 // This internal padding is in addition to the user-supplied padding.
595 // Matches the FF behavior. 632 // Matches the FF behavior.
(...skipping 14 matching lines...) Expand all
610 // static 647 // static
611 void RenderThemeChromiumWin::setFindInPageMode(bool enable) { 648 void RenderThemeChromiumWin::setFindInPageMode(bool enable) {
612 if (m_findInPageMode == enable) 649 if (m_findInPageMode == enable)
613 return; 650 return;
614 651
615 m_findInPageMode = enable; 652 m_findInPageMode = enable;
616 theme()->platformColorsDidChange(); 653 theme()->platformColorsDidChange();
617 } 654 }
618 655
619 } // namespace WebCore 656 } // namespace WebCore
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/platform/graphics/skia/ImageSkia.cpp ('k') | webkit/build/WebCore/WebCore.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698