WebCore:
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jun 2006 20:20:45 +0000 (20:20 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jun 2006 20:20:45 +0000 (20:20 +0000)
        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: https://svn.webkit.org/repository/webkit/trunk@14784 268f45cc-cd09-0410-ab3c-d52691b4dbfc

34 files changed:
WebCore/ChangeLog
WebCore/bridge/mac/FrameMac.h
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/css/cssstyleselector.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/platform/Color.cpp
WebCore/platform/Color.h
WebCore/platform/GraphicsContext.cpp
WebCore/platform/GraphicsContext.h
WebCore/platform/mac/GraphicsContextMac.mm
WebCore/platform/win/TemporaryLinkStubs.cpp
WebCore/rendering/InlineTextBox.cpp
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderHTMLCanvas.cpp
WebCore/rendering/RenderImage.cpp
WebCore/rendering/RenderListMarker.cpp
WebCore/rendering/RenderListMarker.h
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderReplaced.cpp
WebCore/rendering/RenderReplaced.h
WebCore/rendering/RenderTheme.cpp
WebCore/rendering/RenderTheme.h
WebCore/rendering/RenderThemeMac.h
WebCore/rendering/RenderThemeMac.mm
WebCore/rendering/RenderThemeWin.cpp
WebCore/rendering/RenderThemeWin.h
WebCore/rendering/RenderWidget.cpp
WebKit/ChangeLog
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebHTMLView.m

index df42eaf083ac151ed4bb3d270f3767923618028c..ca8810bee124c94387c2502565543f11993b40be 100644 (file)
@@ -1,3 +1,74 @@
+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
index c0d9445bc19894d98929f9f01e40ef95d8dcf441..ce382c3d36c8a302a499f6aba46ba2f7b667e748 100644 (file)
@@ -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);
index 69460ff65df1d3dd2c97fdf92c8c286367a17ae1..adb45bf4a27b4cfcb4df580fa98099794388fd39 100644 (file)
@@ -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.
index 0f3847833412f8c400b49890735a3a7cadffaba5..6b780b27df568f80eaf973bb2a61a8edd875a862 100644 (file)
@@ -335,7 +335,7 @@ typedef enum {
 - (NSString *)selectedString;
 
 - (void)setSelectionFromNone;
-- (void)setDisplaysWithFocusAttributes:(BOOL)flag;
+- (void)setIsActive:(BOOL)flag;
 
 - (void)setWindowHasFocus:(BOOL)flag;
 
index 57aefc1ca571df2188bdb70c13bbf4bf7eb85243..7c468224484c14383cd850dad9e7209fa60b4078 100644 (file)
@@ -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
index 19cef2ff2884456b3f69f5eea9aba72ca91a62e1..6173533bc713a7125147ab0bccb14710b151cb11 100644 (file)
@@ -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
index 25708e5a47b03e37bbdeb0af9f6bcbbe07899f41..4277921b7973fb218628286e3e88fd435f95b96b 100644 (file)
@@ -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;
index bb0d1f3527c5bef511a456315321b1e59fa2b45c..49a6061b30b2d1b6d462da3aab5513f6525c74e6 100644 (file)
@@ -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.
 
index 8312f413f16ddf23335d5bfd3e28dcfc15f21eee..3a974deb05a44bc9b175e7d1ba23d7775f61cc01 100644 (file)
@@ -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;
index 7c3b7e42725ec6fd437836084bec942dc3c0a52d..53d26b9052472066e217ca2f0aade40f6f25681b 100644 (file)
@@ -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;
index cf858bbb4ca79c88a664698c55190593f57b7553..50928a7ec2a5a4008addf68c324f8597a3f53353 100644 (file)
@@ -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;
index 2b004bf7925a70044f95e8ed141d1039a47e38ea..35ad7b6434337305523ca47c96fa5b00202373a4 100644 (file)
@@ -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);
index 4c9da7c2536d32987acae31ed9499deb59ffc2a5..86ce340f64601d2f7c81130798175b5a7533870a 100644 (file)
@@ -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.
index fd74f6148486b211ba57d9c12bac39030e801a49..206f1f594bf12b64c724ebc07808e5471c239062 100644 (file)
@@ -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) { }
index 7defc66f1f0310d00a1a67f1ce84bbd87079680f..4e548e57a74ecc1624b999cb7f328042264b560d 100644 (file)
@@ -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;
 
index f4a0b444a17770a1a64402a26776d8af678a69af..9b376d35a6afaf2928e853d59102d68eb2eb19e3 100644 (file)
@@ -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;
 }
 
index d8202f741a70a0a91918f5419fb92b91fa547d98..ea937adf5eb3a58cb905b3f70a4282c21cef08dc 100644 (file)
@@ -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()
index 0d3dab247d7cdc9a845b71c119ceae7b66261b06..778a0ad0e81b53908d971b229fb839344e4bc738 100644 (file)
@@ -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());
     }
 }
 
index c316ced3fca02f32f5c5b528deb25f610b67135a..6db32d83855125adc52d455d4f160a0d60e790de 100644 (file)
@@ -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;
-}
-
 }
index 7c9d7e96bfb71f4bea37b56383fd73c6f3ca078c..64bd334c14473a92524800ffae8ddb6eb05bddfb 100644 (file)
@@ -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:
index f3abe405713cdc24a612b53773870f1c08d9afbe..05544c9d9d15cb7272d899a3c0a2dcbdad25d3de 100644 (file)
@@ -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;
index f54d541e52c416f940687c9220fd008620af76a8..142a1ea5a77737d7b010a3485c43a506c507c418 100644 (file)
@@ -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; }
index 68d771be0cb595469fe64e55d07d88e02c56b67e..22a786ea3f3323818a61eb9f702e46252ce7140d 100644 (file)
@@ -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;
-}
 }
index e9c5344fa6206ff49d0c5fed14ea66348235d15e..51e8b00b40a35d9820cd7d61761ae49b7f082654 100644 (file)
@@ -63,7 +63,6 @@ public:
     virtual void setSelectionState(SelectionState);
     virtual IntRect selectionRect();
     bool isSelected();
-    virtual Color selectionColor(GraphicsContext*) const;
 
 protected:
     int m_intrinsicWidth;
index 2eb1daf57e83f6e16be84dc8e5e05e122222ed60..a05307f1958d698abcc5315432e44a7e56e07b1c 100644 (file)
@@ -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();
index 7fb4e329690e015125ceb135affa87a3dd613006..5a7d9787337bac1762fdbf073b5a0eb310c4a2fc 100644 (file)
@@ -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;
index d7b4ac73cfd922b095c6c5e97ae871bd2bee7d5e..6de16b8209663efb0de39a9b55aa06d0883b8db6 100644 (file)
@@ -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);
index 20f9661fd5b9990b48ebe2de583cc32db527a89a..d35747b3c20f9851f9c623a87dc26efed85758c5 100644 (file)
@@ -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
 {
index 941534585efcef58b3c7f8f56f144fce0d33b29c..cde51208b6118ef525f8023b776ad6d47a5040b2 100644 (file)
@@ -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
index 303ba9b6b1340b1e63deffe841272c2999fd61da..f9ebefd8b8bd7dd969744683e6cc542956949b38 100644 (file)
@@ -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 bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
     { return paintButton(o, i, r); }
     virtual void setCheckboxSize(RenderStyle*) const;
index 7e1572e62388c1f5dc0802cc451af2257a3f1888..cd8145b73d4190d3d3083489e8535c7d7574a888 100644 (file)
@@ -192,7 +192,7 @@ void RenderWidget::paint(PaintInfo& i, int tx, int ty)
 
     // Paint a partially transparent wash over selected widgets.
     if (isSelected() && !document()->printing())
-        i.p->fillRect(selectionRect(), selectionColor(i.p));
+        i.p->fillRect(selectionRect(), selectionColor());
 }
 
 void RenderWidget::focusIn(Widget*)
index 35439258e521ca0084b54910643514cdf6a0c465..0ace5a95585c1255f936ad8422f58c0f36034526 100644 (file)
@@ -1,3 +1,13 @@
+2006-06-09  David Hyatt  <hyatt@apple.com>
+
+        Rename displaysWithFocusAttributes to isActive.
+
+        Reviewed by sfalken
+
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebView/WebHTMLView.m:
+        (-[WebHTMLView _updateFocusState]):
+
 2006-06-08  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
index 618fcd75289cbbb7111b779a1f13bc529e5b1c01..07f0b5fff0a72b94dd45802f661e089ef8c627e0 100644 (file)
                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               BCF532600A38D00E00976994 /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               BCF532610A38D00E00976994 /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXFileReference section */
                1C68F640095B5FC100C2984E /* webInspector */ = {isa = PBXFileReference; lastKnownFileType = folder; name = webInspector; path = WebInspector/webInspector; sourceTree = SOURCE_ROOT; };
                1C68F65C095B5FC100C2984E /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               BCF532600A38D00E00976994 /* Development */,
+                               BCF532610A38D00E00976994 /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index e24e44bc376ef7a69c9c84f6b463ee41ae22b236..75aa40dd6af3947effe02f643989ca826a330ef1 100644 (file)
@@ -1779,10 +1779,10 @@ static WebHTMLView *lastHitView = nil;
     BOOL windowIsKey = [window isKeyWindow];
     BOOL windowOrSheetIsKey = windowIsKey || [[window attachedSheet] isKeyWindow];
 
-    BOOL displaysWithFocusAttributes = !_private->resigningFirstResponder && windowIsKey && (_private->descendantBecomingFirstResponder || [self _web_firstResponderCausesFocusDisplay]);
+    BOOL isActive = !_private->resigningFirstResponder && windowIsKey && (_private->descendantBecomingFirstResponder || [self _web_firstResponderCausesFocusDisplay]);
     
     [[self _bridge] setWindowHasFocus:windowOrSheetIsKey];
-    [[self _bridge] setDisplaysWithFocusAttributes:displaysWithFocusAttributes];
+    [[self _bridge] setIsActive:isActive];
 }
 
 - (unsigned)highlightAllMatchesForString:(NSString *)string caseSensitive:(BOOL)caseFlag