[webkit-changes] cvs commit: WebCore/kwq KWQKHTMLPart.mm KWQPainter.h KWQPainter.mm WebCoreBridge.mm

David hyatt at opensource.apple.com
Thu Jul 28 13:47:32 PDT 2005


hyatt       05/07/28 13:47:31

  Modified:    .        ChangeLog
               khtml    khtml_part.h
               khtml/css cssstyleselector.cpp
               khtml/rendering render_theme.cpp render_theme.h
                        render_theme_mac.h render_theme_mac.mm
               kwq      KWQKHTMLPart.mm KWQPainter.h KWQPainter.mm
                        WebCoreBridge.mm
  Log:
  	Make sure :focus is not matched when the window is not key.
  	This involved adding a check to the style selector and also
  	removing the hack from the painter that turned off outline:auto
  	drawing when the window wasn't key.
  
  	Added support for control tinting when the window resigns/becomes
  	key.
  
          Reviewed by john
  
          * khtml/css/cssstyleselector.cpp:
          (khtml::CSSStyleSelector::checkOneSelector):
          * khtml/khtml_part.h:
          (KHTMLPart::displaysWithFocusAttributes):
          * khtml/rendering/render_theme.cpp:
          (khtml::RenderTheme::paint):
          (khtml::RenderTheme::isChecked):
          (khtml::RenderTheme::isEnabled):
          (khtml::RenderTheme::isFocused):
          (khtml::RenderTheme::isPressed):
          * khtml/rendering/render_theme.h:
          (khtml::RenderTheme::controlSupportsTints):
          * khtml/rendering/render_theme_mac.h:
          * khtml/rendering/render_theme_mac.mm:
          (khtml::RenderThemeMac::controlSupportsTints):
          * kwq/KWQKHTMLPart.mm:
          (KWQKHTMLPart::setDisplaysWithFocusAttributes):
          * kwq/KWQPainter.h:
          (QPainter::updatingControlTints):
          (QPainter::setUpdatingControlTints):
          * kwq/KWQPainter.mm:
          (QPainter::QPainter):
          (QPainter::initFocusRing):
          (QPainter::addFocusRingRect):
          (QPainter::drawFocusRing):
          * kwq/WebCoreBridge.mm:
          (-[WebCoreBridge drawRect:]):
  
  Revision  Changes    Path
  1.4483    +40 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4482
  retrieving revision 1.4483
  diff -u -r1.4482 -r1.4483
  --- ChangeLog	28 Jul 2005 05:15:41 -0000	1.4482
  +++ ChangeLog	28 Jul 2005 20:47:15 -0000	1.4483
  @@ -1,3 +1,43 @@
  +2005-07-28  David Hyatt  <hyatt at apple.com>
  +
  +	Make sure :focus is not matched when the window is not key.
  +	This involved adding a check to the style selector and also
  +	removing the hack from the painter that turned off outline:auto
  +	drawing when the window wasn't key.
  +
  +	Added support for control tinting when the window resigns/becomes
  +	key.
  +	
  +        Reviewed by john
  +
  +        * khtml/css/cssstyleselector.cpp:
  +        (khtml::CSSStyleSelector::checkOneSelector):
  +        * khtml/khtml_part.h:
  +        (KHTMLPart::displaysWithFocusAttributes):
  +        * khtml/rendering/render_theme.cpp:
  +        (khtml::RenderTheme::paint):
  +        (khtml::RenderTheme::isChecked):
  +        (khtml::RenderTheme::isEnabled):
  +        (khtml::RenderTheme::isFocused):
  +        (khtml::RenderTheme::isPressed):
  +        * khtml/rendering/render_theme.h:
  +        (khtml::RenderTheme::controlSupportsTints):
  +        * khtml/rendering/render_theme_mac.h:
  +        * khtml/rendering/render_theme_mac.mm:
  +        (khtml::RenderThemeMac::controlSupportsTints):
  +        * kwq/KWQKHTMLPart.mm:
  +        (KWQKHTMLPart::setDisplaysWithFocusAttributes):
  +        * kwq/KWQPainter.h:
  +        (QPainter::updatingControlTints):
  +        (QPainter::setUpdatingControlTints):
  +        * kwq/KWQPainter.mm:
  +        (QPainter::QPainter):
  +        (QPainter::initFocusRing):
  +        (QPainter::addFocusRingRect):
  +        (QPainter::drawFocusRing):
  +        * kwq/WebCoreBridge.mm:
  +        (-[WebCoreBridge drawRect:]):
  +
   2005-07-27  Justin Garcia  <justin.garcia at apple.com>
   
           Reviewed by ken
  
  
  
  1.134     +2 -0      WebCore/khtml/khtml_part.h
  
  Index: khtml_part.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/khtml_part.h,v
  retrieving revision 1.133
  retrieving revision 1.134
  diff -u -r1.133 -r1.134
  --- khtml_part.h	14 Jun 2005 00:23:44 -0000	1.133
  +++ khtml_part.h	28 Jul 2005 20:47:24 -0000	1.134
  @@ -934,6 +934,8 @@
     void print();
     virtual bool isCharacterSmartReplaceExempt(const QChar &, bool);
   
  +  virtual bool displaysWithFocusAttributes() const { return true; }
  +    
     // Used to keep the part alive when running a script that might destroy it.
     void keepAlive();
   
  
  
  
  1.195     +1 -1      WebCore/khtml/css/cssstyleselector.cpp
  
  Index: cssstyleselector.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
  retrieving revision 1.194
  retrieving revision 1.195
  diff -u -r1.194 -r1.195
  --- cssstyleselector.cpp	27 Jul 2005 01:12:27 -0000	1.194
  +++ cssstyleselector.cpp	28 Jul 2005 20:47:25 -0000	1.195
  @@ -1318,7 +1318,7 @@
                   break;
               }
               case CSSSelector::PseudoFocus:
  -                if (e && e->focused()) {
  +                if (e && e->focused() && e->getDocument()->part()->displaysWithFocusAttributes()) {
                       return true;
                   }
                   break;
  
  
  
  1.3       +15 -4     WebCore/khtml/rendering/render_theme.cpp
  
  Index: render_theme.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- render_theme.cpp	27 Jul 2005 01:12:28 -0000	1.2
  +++ render_theme.cpp	28 Jul 2005 20:47:26 -0000	1.3
  @@ -50,6 +50,17 @@
   
   void RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
   {
  +    // If painting is disabled, but we aren't updating control tints, then just bail.
  +    // If we are updating control tints, just schedule a repaint if the theme supports tinting
  +    // for that control.
  +    if (i.p->updatingControlTints()) {
  +        if (controlSupportsTints(o))
  +            o->repaint();
  +        return;
  +    }
  +    if (i.p->paintingDisabled())
  +        return;
  +        
       // Call the appropriate paint method based off the appearance value.
       switch (o->style()->appearance()) {
           case CheckboxAppearance:
  @@ -64,28 +75,28 @@
       return o->height() + o->marginTop() + o->marginBottom();
   }
   
  -bool RenderTheme::isChecked(const RenderObject* o)
  +bool RenderTheme::isChecked(const RenderObject* o) const
   {
       if (!o->element() || !o->element()->hasTagName(HTMLTags::input()))
           return false;
       return static_cast<HTMLInputElementImpl*>(o->element())->checked();
   }
   
  -bool RenderTheme::isEnabled(const RenderObject* o)
  +bool RenderTheme::isEnabled(const RenderObject* o) const
   {
       if (!o->element() || !o->element()->hasTagName(HTMLTags::input()))
           return true;
       return !static_cast<HTMLInputElementImpl*>(o->element())->disabled();
   }
   
  -bool RenderTheme::isFocused(const RenderObject* o)
  +bool RenderTheme::isFocused(const RenderObject* o) const
   {
       if (!o->element())
           return false;
       return o->element() == o->element()->getDocument()->focusNode();
   }
   
  -bool RenderTheme::isPressed(const RenderObject* o)
  +bool RenderTheme::isPressed(const RenderObject* o) const
   {
       if (!o->element())
           return false;
  
  
  
  1.4       +7 -4      WebCore/khtml/rendering/render_theme.h
  
  Index: render_theme.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- render_theme.h	27 Jul 2005 01:12:28 -0000	1.3
  +++ render_theme.h	28 Jul 2005 20:47:26 -0000	1.4
  @@ -57,6 +57,9 @@
       // the baseline position API above).
       virtual bool isControlContainer(EAppearance appearance) const { return true; }
   
  +    // An API asking if the control changes its tint when the window has focus or not.
  +    virtual bool controlSupportsTints(const RenderObject* o) const { return false; }
  +
       // Some controls may spill out of their containers (e.g., the check on an OS X checkbox).  When these controls repaint,
       // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control.
       virtual void adjustRepaintRect(const RenderObject* o, QRect& r) { }
  @@ -67,10 +70,10 @@
   
   protected:
       // Methods for state querying
  -    bool isChecked(const RenderObject* o);
  -    bool isEnabled(const RenderObject* o);
  -    bool isFocused(const RenderObject* o);
  -    bool isPressed(const RenderObject* o);
  +    bool isChecked(const RenderObject* o) const;
  +    bool isEnabled(const RenderObject* o) const;
  +    bool isFocused(const RenderObject* o) const;
  +    bool isPressed(const RenderObject* o) const;
   
       // Methods for each appearance value.
       virtual void adjustCheckboxStyle(RenderStyle* style) const = 0;
  
  
  
  1.3       +3 -0      WebCore/khtml/rendering/render_theme_mac.h
  
  Index: render_theme_mac.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme_mac.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- render_theme_mac.h	27 Jul 2005 01:12:28 -0000	1.2
  +++ render_theme_mac.h	28 Jul 2005 20:47:26 -0000	1.3
  @@ -43,6 +43,9 @@
       // the baseline position API above).
       virtual bool isControlContainer(EAppearance appearance) const;
   
  +    // An API asking if the control changes its tint when the window has focus or not.
  +    virtual bool controlSupportsTints(const RenderObject* o) const;
  +
       virtual void adjustRepaintRect(const RenderObject* o, QRect& r);
   
   protected:
  
  
  
  1.4       +13 -0     WebCore/khtml/rendering/render_theme_mac.mm
  
  Index: render_theme_mac.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme_mac.mm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- render_theme_mac.mm	27 Jul 2005 18:55:40 -0000	1.3
  +++ render_theme_mac.mm	28 Jul 2005 20:47:26 -0000	1.4
  @@ -125,7 +125,20 @@
       // more controls.
       return appearance != CheckboxAppearance && appearance != RadioAppearance;
   }
  +
  +bool RenderThemeMac::controlSupportsTints(const RenderObject* o) const
  +{
  +    if (!isEnabled(o))
  +        return false;
  +    
  +    // Checkboxes only have tint when checked.
  +    if (o->style()->appearance() == CheckboxAppearance)
  +        return isChecked(o);
       
  +    // For now assume other controls have tint if enabled.
  +    return true;
  +}
  +
   NSControlSize RenderThemeMac::controlSizeForFont(RenderStyle* style) const
   {
       int fontSize = style->fontSize();
  
  
  
  1.653     +18 -3     WebCore/kwq/KWQKHTMLPart.mm
  
  Index: KWQKHTMLPart.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
  retrieving revision 1.652
  retrieving revision 1.653
  diff -u -r1.652 -r1.653
  --- KWQKHTMLPart.mm	20 Jul 2005 19:55:12 -0000	1.652
  +++ KWQKHTMLPart.mm	28 Jul 2005 20:47:27 -0000	1.653
  @@ -3704,7 +3704,7 @@
       d->m_isFocused = flag;
   
       // This method does the job of updating the view based on whether the view is "active".
  -    // This involves three kinds of drawing updates:
  +    // This involves four kinds of drawing updates:
   
       // 1. The background color used to draw behind selected content (active | inactive color)
       if (d->m_view)
  @@ -3719,8 +3719,23 @@
       DocumentImpl *doc = xmlDocImpl();
       if (doc) {
           NodeImpl *node = doc->focusNode();
  -        if (node && node->renderer())
  -            node->renderer()->repaint();
  +        if (node) {
  +            node->setChanged();
  +            // FIXME: Let the theme decide whether it needs to repaint or not in response to focus
  +            // activation.
  +            if (node->renderer() && node->renderer()->style()->hasAppearance())
  +                node->renderer()->repaint();
  +        }
  +    }
  +    
  +    // 4. 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.
  +    NSView *documentView = d->m_view ? d->m_view->getDocumentView() : 0;
  +    if (documentView && renderer()) {
  +        QRect visibleRect([documentView visibleRect]);
  +        QPainter p;
  +        p.setUpdatingControlTints(true);
  +        paint(&p, visibleRect);
       }
   }
   
  
  
  
  1.74      +5 -3      WebCore/kwq/KWQPainter.h
  
  Index: KWQPainter.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQPainter.h,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- KWQPainter.h	5 Jul 2005 23:21:16 -0000	1.73
  +++ KWQPainter.h	28 Jul 2005 20:47:28 -0000	1.74
  @@ -118,7 +118,10 @@
       
       bool paintingDisabled() const;
       void setPaintingDisabled(bool);
  -        
  +    
  +    bool updatingControlTints() const { return _updatingControlTints; }
  +    void setUpdatingControlTints(bool b) { setPaintingDisabled(b); _updatingControlTints = b; }
  +
       void beginTransparencyLayer(float opacity);
       void endTransparencyLayer();
   
  @@ -130,7 +133,6 @@
       void addFocusRingRect(int x, int y, int width, int height);
       void drawFocusRing();
       void clearFocusRing();
  -    void setDrawsFocusRing(bool flag) { _drawsFocusRing = flag; }
       
       CGContextRef currentContext();
       
  @@ -160,7 +162,7 @@
       QPainterPrivate *data;
       bool _isForPrinting;
       bool _usesInactiveTextBackgroundColor;
  -    bool _drawsFocusRing;
  +    bool _updatingControlTints;
   };
   
   #endif
  
  
  
  1.128     +3 -14     WebCore/kwq/KWQPainter.mm
  
  Index: KWQPainter.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQPainter.mm,v
  retrieving revision 1.127
  retrieving revision 1.128
  diff -u -r1.127 -r1.128
  --- KWQPainter.mm	7 Jul 2005 08:03:22 -0000	1.127
  +++ KWQPainter.mm	28 Jul 2005 20:47:28 -0000	1.128
  @@ -70,11 +70,12 @@
       QColor focusRingColor;
   };
   
  -QPainter::QPainter() : data(new QPainterPrivate), _isForPrinting(false), _usesInactiveTextBackgroundColor(false), _drawsFocusRing(true)
  +QPainter::QPainter() : data(new QPainterPrivate), _isForPrinting(false), _usesInactiveTextBackgroundColor(false), _updatingControlTints(false)
   {
   }
   
  -QPainter::QPainter(bool forPrinting) : data(new QPainterPrivate), _isForPrinting(forPrinting), _usesInactiveTextBackgroundColor(false), _drawsFocusRing(true)
  +QPainter::QPainter(bool forPrinting) : data(new QPainterPrivate), _isForPrinting(forPrinting), 
  +    _usesInactiveTextBackgroundColor(false), _updatingControlTints(false)
   {
   }
   
  @@ -831,9 +832,6 @@
   
   void QPainter::initFocusRing(int width, int offset)
   {
  -    if (!_drawsFocusRing)
  -        return;
  -
       clearFocusRing();
       data->focusRingWidth = width;
       data->hasFocusRingColor = false;
  @@ -844,9 +842,6 @@
   
   void QPainter::initFocusRing(int width, int offset, const QColor &color)
   {
  -    if (!_drawsFocusRing)
  -        return;
  -
       initFocusRing(width, offset);
       data->hasFocusRingColor = true;
       data->focusRingColor = color;
  @@ -854,9 +849,6 @@
   
   void QPainter::addFocusRingRect(int x, int y, int width, int height)
   {
  -    if (!_drawsFocusRing)
  -        return;
  -
       ASSERT(data->focusRingPath);
       NSRect rect = NSMakeRect(x, y, width, height);
       int offset = (data->focusRingWidth-1)/2 + data->focusRingOffset;
  @@ -866,9 +858,6 @@
   
   void QPainter::drawFocusRing()
   {
  -    if (!_drawsFocusRing)
  -        return;
  -    
       ASSERT(data->focusRingPath);
       if (data->state.paintingDisabled)
           return;
  
  
  
  1.405     +0 -1      WebCore/kwq/WebCoreBridge.mm
  
  Index: WebCoreBridge.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.mm,v
  retrieving revision 1.404
  retrieving revision 1.405
  diff -u -r1.404 -r1.405
  --- WebCoreBridge.mm	22 Jul 2005 18:09:22 -0000	1.404
  +++ WebCoreBridge.mm	28 Jul 2005 20:47:29 -0000	1.405
  @@ -717,7 +717,6 @@
       QPainter painter(nowPrinting(self));
       bool displaysWithFocusAttributes = _part->displaysWithFocusAttributes();
       painter.setUsesInactiveTextBackgroundColor(!displaysWithFocusAttributes);
  -    painter.setDrawsFocusRing(displaysWithFocusAttributes);
       [self drawRect:rect withPainter:&painter];
   }
   
  
  
  



More information about the webkit-changes mailing list