Commit 76a0c024 authored by hyatt's avatar hyatt

WebCore:

        Rework selection coloring.  Rename displaysWithFocusAttributes
        to isActive.  Move the white-blending code onto the Color API to make
        it more convenient to mutate colors for selection blending.  Eliminate all
        the selection state from the GraphicsContext and move it to the RenderTheme.
        Implement both Win32 and Mac theme selection colors.

        Reviewed by sfalken

        * bridge/mac/FrameMac.h:
        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::setIsActive):
        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge drawRect:]):
        (-[WebCoreFrameBridge setIsActive:]):
        (-[WebCoreFrameBridge selectionColor]):
        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::checkOneSelector):
        * page/Frame.cpp:
        (WebCore::Frame::isActive):
        (WebCore::Frame::setIsActive):
        * page/Frame.h:
        * platform/Color.cpp:
        (WebCore::blend):
        (WebCore::Color::blendWithWhite):
        * platform/Color.h:
        (WebCore::Color::hasAlpha):
        * platform/GraphicsContext.cpp:
        (WebCore::GraphicsContextPrivate::GraphicsContextPrivate):
        * platform/GraphicsContext.h:
        * platform/mac/GraphicsContextMac.mm:
        * platform/win/TemporaryLinkStubs.cpp:
        (GraphicsContext::endTransparencyLayer):
        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::paintSelection):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::fillHorizontalSelectionGap):
        (WebCore::RenderBlock::fillVerticalSelectionGap):
        (WebCore::RenderBlock::fillLeftSelectionGap):
        (WebCore::RenderBlock::fillRightSelectionGap):
        * rendering/RenderHTMLCanvas.cpp:
        (WebCore::RenderHTMLCanvas::paint):
        * rendering/RenderImage.cpp:
        (WebCore::RenderImage::paint):
        * rendering/RenderListMarker.cpp:
        (WebCore::RenderListMarker::paint):
        * rendering/RenderListMarker.h:
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::selectionColor):
        * rendering/RenderObject.h:
        * rendering/RenderReplaced.cpp:
        * rendering/RenderReplaced.h:
        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::activeSelectionColor):
        (WebCore::RenderTheme::inactiveSelectionColor):
        (WebCore::RenderTheme::platformActiveSelectionColor):
        (WebCore::RenderTheme::platformInactiveSelectionColor):
        * rendering/RenderTheme.h:
        * rendering/RenderThemeMac.h:
        * rendering/RenderThemeMac.mm:
        (WebCore::RenderThemeMac::platformActiveSelectionColor):
        (WebCore::RenderThemeMac::platformInactiveSelectionColor):
        * rendering/RenderThemeWin.cpp:
        (WebCore::RenderThemeWin::platformActiveSelectionColor):
        (WebCore::RenderThemeWin::platformInactiveSelectionColor):
        * rendering/RenderThemeWin.h:
        * rendering/RenderWidget.cpp:
        (WebCore::RenderWidget::paint):

WebKit:

        Rename displaysWithFocusAttributes to isActive.

        Reviewed by sfalken

        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebHTMLView.m:
        (-[WebHTMLView _updateFocusState]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14784 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7c9568d1
2006-06-09 David Hyatt <hyatt@apple.com>
Rework selection coloring. Rename displaysWithFocusAttributes
to isActive. Move the white-blending code onto the Color API to make
it more convenient to mutate colors for selection blending. Eliminate all
the selection state from the GraphicsContext and move it to the RenderTheme.
Implement both Win32 and Mac theme selection colors.
Reviewed by sfalken
* bridge/mac/FrameMac.h:
* bridge/mac/FrameMac.mm:
(WebCore::FrameMac::setIsActive):
* bridge/mac/WebCoreFrameBridge.h:
* bridge/mac/WebCoreFrameBridge.mm:
(-[WebCoreFrameBridge drawRect:]):
(-[WebCoreFrameBridge setIsActive:]):
(-[WebCoreFrameBridge selectionColor]):
* css/cssstyleselector.cpp:
(WebCore::CSSStyleSelector::checkOneSelector):
* page/Frame.cpp:
(WebCore::Frame::isActive):
(WebCore::Frame::setIsActive):
* page/Frame.h:
* platform/Color.cpp:
(WebCore::blend):
(WebCore::Color::blendWithWhite):
* platform/Color.h:
(WebCore::Color::hasAlpha):
* platform/GraphicsContext.cpp:
(WebCore::GraphicsContextPrivate::GraphicsContextPrivate):
* platform/GraphicsContext.h:
* platform/mac/GraphicsContextMac.mm:
* platform/win/TemporaryLinkStubs.cpp:
(GraphicsContext::endTransparencyLayer):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintSelection):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::fillHorizontalSelectionGap):
(WebCore::RenderBlock::fillVerticalSelectionGap):
(WebCore::RenderBlock::fillLeftSelectionGap):
(WebCore::RenderBlock::fillRightSelectionGap):
* rendering/RenderHTMLCanvas.cpp:
(WebCore::RenderHTMLCanvas::paint):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paint):
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::paint):
* rendering/RenderListMarker.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::selectionColor):
* rendering/RenderObject.h:
* rendering/RenderReplaced.cpp:
* rendering/RenderReplaced.h:
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::activeSelectionColor):
(WebCore::RenderTheme::inactiveSelectionColor):
(WebCore::RenderTheme::platformActiveSelectionColor):
(WebCore::RenderTheme::platformInactiveSelectionColor):
* rendering/RenderTheme.h:
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::platformActiveSelectionColor):
(WebCore::RenderThemeMac::platformInactiveSelectionColor):
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::platformActiveSelectionColor):
(WebCore::RenderThemeWin::platformInactiveSelectionColor):
* rendering/RenderThemeWin.h:
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::paint):
2006-06-09 Justin Garcia <justin.garcia@apple.com>
Reviewed by levi
......
......@@ -149,7 +149,7 @@ public:
virtual void restoreDocumentState();
virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID);
virtual void setDisplaysWithFocusAttributes(bool);
virtual void setIsActive(bool);
NSView* nextKeyView(Node* startingPoint, KWQSelectionDirection);
NSView* nextKeyViewInFrameHierarchy(Node* startingPoint, KWQSelectionDirection);
......
......@@ -2846,12 +2846,12 @@ String FrameMac::overrideMediaType() const
return String();
}
void FrameMac::setDisplaysWithFocusAttributes(bool flag)
void FrameMac::setIsActive(bool flag)
{
if (d->m_isFocused == flag)
return;
Frame::setDisplaysWithFocusAttributes(flag);
Frame::setIsActive(flag);
Document *doc = document();
// Mac Specific: Changing the tint of controls from clear to aqua/graphite and vice versa. We
// do a "fake" paint. When the theme gets a paint call, it can then do an invalidate.
......
......@@ -335,7 +335,7 @@ typedef enum {
- (NSString *)selectedString;
- (void)setSelectionFromNone;
- (void)setDisplaysWithFocusAttributes:(BOOL)flag;
- (void)setIsActive:(BOOL)flag;
- (void)setWindowHasFocus:(BOOL)flag;
......
......@@ -896,7 +896,6 @@ static BOOL nowPrinting(WebCoreFrameBridge *self)
ASSERT([[NSGraphicsContext currentContext] isFlipped]);
ASSERT(!m_frame->document() || m_frame->document()->printing() == ![NSGraphicsContext currentContextDrawingToScreen]);
GraphicsContext context(platformContext);
context.setUsesInactiveTextBackgroundColor(!m_frame->displaysWithFocusAttributes());
[self _setupRootForPrinting:YES];
m_frame->paint(&context, enclosingIntRect(rect));
[self _setupRootForPrinting:NO];
......@@ -1469,9 +1468,9 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
m_frame->setSelectionFromNone();
}
- (void)setDisplaysWithFocusAttributes:(BOOL)flag
- (void)setIsActive:(BOOL)flag
{
m_frame->setDisplaysWithFocusAttributes(flag);
m_frame->setIsActive(flag);
}
- (void)setWindowHasFocus:(BOOL)flag
......@@ -1519,16 +1518,10 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
return m_frame->bodyBackgroundColor();
}
// FIXME: Not sure what this method is for. It seems to only be used by plug-ins over in WebKit.
- (NSColor *)selectionColor
{
RenderView* root = static_cast<RenderView *>(m_frame->document()->renderer());
if (root) {
RenderStyle *pseudoStyle = root->getPseudoStyle(RenderStyle::SELECTION);
if (pseudoStyle && pseudoStyle->backgroundColor().isValid()) {
return nsColor(pseudoStyle->backgroundColor());
}
}
return m_frame->displaysWithFocusAttributes() ? [NSColor selectedTextBackgroundColor] : [NSColor secondarySelectedControlColor];
return m_frame->isActive() ? [NSColor selectedTextBackgroundColor] : [NSColor secondarySelectedControlColor];
}
- (void)adjustViewSize
......
......@@ -1482,9 +1482,8 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isSub
break;
}
case CSSSelector::PseudoFocus:
if (e && e->focused() && e->document()->frame()->displaysWithFocusAttributes()) {
if (e && e->focused() && e->document()->frame()->isActive())
return true;
}
break;
case CSSSelector::PseudoActive:
// If we're in quirks mode, then :active should never match anchors with no
......
......@@ -3282,12 +3282,12 @@ void Frame::setSelectionFromNone()
setSelection(SelectionController(Position(node, 0), DOWNSTREAM));
}
bool Frame::displaysWithFocusAttributes() const
bool Frame::isActive() const
{
return d->m_isFocused;
}
void Frame::setDisplaysWithFocusAttributes(bool flag)
void Frame::setIsActive(bool flag)
{
if (d->m_isFocused == flag)
return;
......
......@@ -712,8 +712,8 @@ private:
void clearTimers();
static void clearTimers(FrameView*);
bool displaysWithFocusAttributes() const;
virtual void setDisplaysWithFocusAttributes(bool flag);
bool isActive() const;
virtual void setIsActive(bool flag);
void setWindowHasFocus(bool flag);
// Convenience, to avoid repeating the code to dig down to get this.
......
......@@ -212,6 +212,27 @@ Color Color::dark() const
return Color((int)(r * 255), (int)(g * 255), (int)(b * 255), (int)(a * 255));
}
static int blend(int c, int a)
{
// We use white.
float alpha = (float)(a) / 255;
int whiteBlend = 255 - a;
c -= whiteBlend;
c = max(0, c);
return min(255, (int)(c / alpha)); // Clamp to be within 0-255
}
Color Color::blendWithWhite(int alpha) const
{
// If the color contains alpha already, we leave it alone.
if (hasAlpha())
return *this;
// We have a solid color. Convert to an equivalent color that looks the same when blended with white
// at the alpha specified.
return Color(blend(red(), alpha), blend(green(), alpha), blend(blue(), alpha), alpha);
}
void Color::getRGBA(float& r, float& g, float& b, float& a) const
{
r = red() / 255.0f;
......
......@@ -64,6 +64,8 @@ public:
bool isValid() const { return valid; }
bool hasAlpha() const { return alpha() < 255; }
int red() const { return (color >> 16) & 0xFF; }
int green() const { return (color >> 8) & 0xFF; }
int blue() const { return color & 0xFF; }
......@@ -77,6 +79,8 @@ public:
Color light() const;
Color dark() const;
Color blendWithWhite(int alpha) const;
static const RGBA32 black = 0xFF000000;
static const RGBA32 white = 0xFFFFFFFF;
static const RGBA32 darkGray = 0xFF808080;
......
......@@ -50,14 +50,12 @@ public:
Vector<IntRect> m_focusRingRects;
int m_focusRingWidth;
int m_focusRingOffset;
bool m_usesInactiveTextBackgroundColor;
bool m_updatingControlTints;
};
GraphicsContextPrivate::GraphicsContextPrivate()
: m_focusRingWidth(0)
, m_focusRingOffset(0)
, m_usesInactiveTextBackgroundColor(false)
, m_updatingControlTints(false)
{
}
......@@ -141,16 +139,6 @@ Color GraphicsContext::fillColor() const
return m_common->state.fillColor;
}
void GraphicsContext::setUsesInactiveTextBackgroundColor(bool u)
{
m_common->m_usesInactiveTextBackgroundColor = u;
}
bool GraphicsContext::usesInactiveTextBackgroundColor() const
{
return m_common->m_usesInactiveTextBackgroundColor;
}
bool GraphicsContext::updatingControlTints() const
{
return m_common->m_updatingControlTints;
......
......@@ -120,10 +120,6 @@ namespace WebCore {
void drawLineForText(const IntPoint&, int yOffset, int width, bool printing);
void drawLineForMisspelling(const IntPoint&, int width);
Color selectedTextBackgroundColor() const;
void setUsesInactiveTextBackgroundColor(bool);
bool usesInactiveTextBackgroundColor() const;
bool paintingDisabled() const;
void setPaintingDisabled(bool);
......
......@@ -70,35 +70,6 @@ GraphicsContext::~GraphicsContext()
delete m_data;
}
static int getBlendedColorComponent(int c, int a)
{
// We use white.
float alpha = (float)(a) / 255;
int whiteBlend = 255 - a;
c -= whiteBlend;
return (int)(c/alpha);
}
Color GraphicsContext::selectedTextBackgroundColor() const
{
NSColor *color = usesInactiveTextBackgroundColor() ? [NSColor secondarySelectedControlColor] : [NSColor selectedTextBackgroundColor];
// this needs to always use device colorspace so it can de-calibrate the color for
// Color to possibly recalibrate it
color = [color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
Color col = Color((int)(255 * [color redComponent]), (int)(255 * [color greenComponent]), (int)(255 * [color blueComponent]));
// Attempt to make the selection 60% transparent. We do this by applying a standard blend and then
// seeing if the resultant color is still within the 0-255 range.
int alpha = 153;
int red = getBlendedColorComponent(col.red(), alpha);
int green = getBlendedColorComponent(col.green(), alpha);
int blue = getBlendedColorComponent(col.blue(), alpha);
if (red >= 0 && red <= 255 && green >= 0 && green <= 255 && blue >= 0 && blue <= 255)
return Color(red, green, blue, alpha);
return col;
}
void GraphicsContext::setFocusRingClip(const IntRect& r)
{
// This method only exists to work around bugs in Mac focus ring clipping.
......
......@@ -276,7 +276,6 @@ void GraphicsContext::setShadow(IntSize const&,int,Color const&) { }
void GraphicsContext::clearShadow() { }
void GraphicsContext::beginTransparencyLayer(float) { }
void GraphicsContext::endTransparencyLayer() { }
Color GraphicsContext::selectedTextBackgroundColor() const { return Color(0,0,255); }
void GraphicsContext::clearRect(const FloatRect&) { }
void GraphicsContext::strokeRect(const FloatRect&, float) { }
void GraphicsContext::setLineWidth(float) { }
......
......@@ -440,7 +440,7 @@ void InlineTextBox::paintSelection(GraphicsContext* p, int tx, int ty, RenderSty
// Macintosh-style text highlighting is to draw with a particular background color, not invert.
Color textColor = style->color();
Color c = object()->selectionColor(p);
Color c = object()->selectionColor();
if (!c.isValid())
return;
......
......@@ -1631,19 +1631,19 @@ GapRects RenderBlock::fillBlockSelectionGaps(RenderBlock* rootBlock, int blockX,
}
IntRect RenderBlock::fillHorizontalSelectionGap(RenderObject* selObj, int xPos, int yPos, int width, int height,
const PaintInfo* i)
const PaintInfo* i)
{
if (width <= 0 || height <= 0)
return IntRect();
IntRect gapRect(xPos, yPos, width, height);
if (i)
i->p->fillRect(gapRect, selObj->selectionColor(i->p));
i->p->fillRect(gapRect, selObj->selectionColor());
return gapRect;
}
IntRect RenderBlock::fillVerticalSelectionGap(int lastTop, int lastLeft, int lastRight,
int bottomY, RenderBlock* rootBlock, int blockX, int blockY,
const PaintInfo* i)
int bottomY, RenderBlock* rootBlock, int blockX, int blockY,
const PaintInfo* i)
{
int top = blockY + lastTop;
int height = bottomY - top;
......@@ -1659,7 +1659,7 @@ IntRect RenderBlock::fillVerticalSelectionGap(int lastTop, int lastLeft, int las
IntRect gapRect(left, top, width, height);
if (i)
i->p->fillRect(gapRect, selectionColor(i->p));
i->p->fillRect(gapRect, selectionColor());
return gapRect;
}
......@@ -1673,7 +1673,7 @@ IntRect RenderBlock::fillLeftSelectionGap(RenderObject* selObj, int xPos, int yP
IntRect gapRect(left, top, width, height);
if (i)
i->p->fillRect(gapRect, selObj->selectionColor(i->p));
i->p->fillRect(gapRect, selObj->selectionColor());
return gapRect;
}
......@@ -1688,7 +1688,7 @@ IntRect RenderBlock::fillRightSelectionGap(RenderObject* selObj, int xPos, int y
IntRect gapRect(left, top, width, height);
if (i)
i->p->fillRect(gapRect, selObj->selectionColor(i->p));
i->p->fillRect(gapRect, selObj->selectionColor());
return gapRect;
}
......
......@@ -77,7 +77,7 @@ void RenderHTMLCanvas::paint(PaintInfo& i, int tx, int ty)
IntRect(x + borderLeft() + paddingLeft(), y + borderTop() + paddingTop(), contentWidth(), contentHeight()));
if (drawSelectionTint)
i.p->fillRect(selectionRect(), selectionColor(i.p));
i.p->fillRect(selectionRect(), selectionColor());
}
void RenderHTMLCanvas::layout()
......
......@@ -266,7 +266,7 @@ void RenderImage::paint(PaintInfo& i, int _tx, int _ty)
p->drawImage(image(), rect, compositeOperator);
if (drawSelectionTint)
p->fillRect(selectionRect(), selectionColor(p));
p->fillRect(selectionRect(), selectionColor());
}
}
......
......@@ -187,7 +187,7 @@ void RenderListMarker::paint(PaintInfo& i, int _tx, int _ty)
if (m_listImage && !m_listImage->isErrorImage()) {
p->drawImage(m_listImage->image(), marker.location());
if (selectionState() != SelectionNone)
p->fillRect(selectionRect(), selectionColor(p));
p->fillRect(selectionRect(), selectionColor());
return;
}
......@@ -197,7 +197,7 @@ void RenderListMarker::paint(PaintInfo& i, int _tx, int _ty)
#endif
if (selectionState() != SelectionNone)
p->fillRect(selectionRect(), selectionColor(p));
p->fillRect(selectionRect(), selectionColor());
const Color color(style()->color());
p->setPen(color);
......@@ -510,15 +510,4 @@ IntRect RenderListMarker::selectionRect()
return IntRect(absx + xPos(), absy + root->selectionTop(), width(), root->selectionHeight());
}
Color RenderListMarker::selectionColor(GraphicsContext* p) const
{
Color color = RenderBox::selectionColor(p);
if (!m_listImage || m_listImage->isErrorImage())
return color;
// Limit the opacity so that no user-specified selection color can obscure selected images.
if (color.alpha() > selectionColorImageOverlayAlpha)
color = Color(color.red(), color.green(), color.blue(), selectionColorImageOverlayAlpha);
return color;
}
}
......@@ -76,7 +76,6 @@ public:
virtual SelectionState selectionState() const { return m_selectionState; }
virtual void setSelectionState(SelectionState);
virtual IntRect selectionRect();
virtual Color selectionColor(GraphicsContext*) const;
virtual bool canBeSelectionLeaf() const { return true; }
private:
......
......@@ -1894,15 +1894,15 @@ bool RenderObject::shouldSelect() const
return false;
}
Color RenderObject::selectionColor(GraphicsContext* p) const
Color RenderObject::selectionColor() const
{
Color color;
if (style()->userSelect() != SELECT_NONE) {
RenderStyle* pseudoStyle = getPseudoStyle(RenderStyle::SELECTION);
if (pseudoStyle && pseudoStyle->backgroundColor().isValid())
color = pseudoStyle->backgroundColor();
color = pseudoStyle->backgroundColor().blendWithWhite(selectionColorOverlayAlpha);
else
color = p->selectedTextBackgroundColor();
color = document()->frame()->isActive() ? theme()->activeSelectionColor() : theme()->inactiveSelectionColor();
}
return color;
......
......@@ -71,7 +71,7 @@ class RenderTable;
class RenderText;
class VisiblePosition;
const int selectionColorImageOverlayAlpha = 60 * 255 / 100;
const int selectionColorOverlayAlpha = 60 * 255 / 100;
enum PaintPhase {
PaintPhaseBlockBackground,
......@@ -794,7 +794,7 @@ public:
bool shouldSelect() const;
// Obtains the selection background color that should be used when painting a selection.
virtual Color selectionColor(GraphicsContext*) const;
Color selectionColor() const;
// Whether or not a given block needs to paint selection gaps.
virtual bool shouldPaintSelectionGaps() const { return false; }
......
......@@ -213,14 +213,4 @@ bool RenderReplaced::isSelected()
return false;
}
Color RenderReplaced::selectionColor(GraphicsContext* p) const
{
Color color = RenderBox::selectionColor(p);
// Limit the opacity so that no user-specified selection color can obscure selected images.
if (color.alpha() > selectionColorImageOverlayAlpha)
color = Color(color.red(), color.green(), color.blue(), selectionColorImageOverlayAlpha);
return color;
}
}
......@@ -63,7 +63,6 @@ public:
virtual void setSelectionState(SelectionState);
virtual IntRect selectionRect();
bool isSelected();
virtual Color selectionColor(GraphicsContext*) const;
protected:
int m_intrinsicWidth;
......
......@@ -120,6 +120,34 @@ bool RenderTheme::paintBorderOnly(RenderObject* o, const RenderObject::PaintInfo
return false;
}
Color RenderTheme::activeSelectionColor() const
{
static Color activeSelectionColor;
if (!activeSelectionColor.isValid())
activeSelectionColor = platformActiveSelectionColor().blendWithWhite(selectionColorOverlayAlpha);
return activeSelectionColor;
}
Color RenderTheme::inactiveSelectionColor() const
{
static Color inactiveSelectionColor;
if (!inactiveSelectionColor.isValid())
inactiveSelectionColor = platformInactiveSelectionColor().blendWithWhite(selectionColorOverlayAlpha);
return inactiveSelectionColor;
}
Color RenderTheme::platformActiveSelectionColor() const
{
// Use a blue color by default if the platform theme doesn't define anything.
return Color(0, 0, 255);
}
Color RenderTheme::platformInactiveSelectionColor() const
{
// Use a grey color by default if the platform theme doesn't define anything.
return Color(128, 128, 128);
}
short RenderTheme::baselinePosition(const RenderObject* o) const
{
return o->height() + o->marginTop();
......
......@@ -88,6 +88,14 @@ public:
// A method asking if the theme's controls actually care about redrawing when hovered.
virtual bool supportsHover(const RenderStyle* style) const { return false; }
// The selection color.
Color activeSelectionColor() const;
Color inactiveSelectionColor() const;
// The platform selection color.
virtual Color platformActiveSelectionColor() const;
virtual Color platformInactiveSelectionColor() const;
protected:
// Methods for state querying
bool isChecked(const RenderObject* o) const;
......
......@@ -52,6 +52,9 @@ public:
virtual void paintResizeControl(GraphicsContext*, const IntRect&);
virtual Color platformActiveSelectionColor() const;
virtual Color platformInactiveSelectionColor() const;
protected:
// Methods for each appearance value.
virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
......
......@@ -56,6 +56,18 @@ RenderThemeMac::RenderThemeMac()
{
}
Color RenderThemeMac::platformActiveSelectionColor() const
{
NSColor* color = [[NSColor selectedTextBackgroundColor] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
return Color((int)(255 * [color redComponent]), (int)(255 * [color greenComponent]), (int)(255 * [color blueComponent]));
}
Color RenderThemeMac::platformInactiveSelectionColor() const
{
NSColor* color = [[NSColor secondarySelectedControlColor] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
return Color((int)(255 * [color redComponent]), (int)(255 * [color greenComponent]), (int)(255 * [color blueComponent]));
}
bool RenderThemeMac::isControlStyled(const RenderStyle* style, const BorderData& border,
const BackgroundLayer& background, const Color& backgroundColor) const
{
......
......@@ -122,6 +122,18 @@ void RenderThemeWin::close()
m_buttonTheme = m_textFieldTheme = 0;
}
Color RenderThemeWin::platformActiveSelectionColor() const
{
COLORREF color = GetSysColor(COLOR_HIGHLIGHTTEXT);
return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
}
Color RenderThemeWin::platformInactiveSelectionColor() const
{
COLORREF color = GetSysColor(COLOR_HIGHLIGHT);
return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
}
void RenderThemeWin::addIntrinsicMargins(RenderStyle* style) const
{
// Cut out the intrinsic margins completely if we end up using a small font size
......
......@@ -48,6 +48,9 @@ public:
// A method asking if the theme's controls actually care about redrawing when hovered.
virtual bool supportsHover(const RenderStyle*) const { return true; }
virtual Color platformActiveSelectionColor() const;
virtual Color platformInactiveSelectionColor() const;
virtual <