[webkit-changes] cvs commit: WebCore/khtml/xml dom_nodeimpl.h

David hyatt at opensource.apple.com
Wed Oct 26 12:44:09 PDT 2005


hyatt       05/10/26 12:44:08

  Modified:    .        ChangeLog
               khtml/css css_base.cpp css_base.h cssstyleselector.cpp
               khtml/ecma kjs_html.cpp kjs_html.h
               khtml/html html_formimpl.cpp html_formimpl.h
               khtml/rendering render_theme.cpp render_theme.h
                        render_theme_mac.mm
               khtml/xml dom_nodeimpl.h
  Log:
  	Add support for the indeterminate boolean for placing checkboxes
  	into a mixed state.  This is a feature of WinIE.
  
  	Along with this feature, add support for the CSS3 :indeterminate
  	selector, although one wonders how this could be part of the selectors spec
  	when no DOM standard covers the ability to make a mixed checkbox
  	in the first place.
  
  	This implementation may seem like it's overlooking some things, but it's not.
  	Specifically "indeterminate" has no effect on form submission, it does not
  	get cleared by a form reset, and the pre/post reversal code for undoing clicks
  	only resets the state that changed in WinIE.  This is all bizarre behavior,
  	but this is a WinIE extension, so we're going to match.
  
          Reviewed by mjs
  
  	fast/forms/indeterminate.html
  
          * khtml/css/css_base.cpp:
          (CSSSelector::extractPseudoType):
          * khtml/css/css_base.h:
          (DOM::CSSSelector::):
          * khtml/css/cssstyleselector.cpp:
          (khtml::CSSStyleSelector::checkOneSelector):
          * khtml/ecma/kjs_html.cpp:
          (KJS::HTMLElement::inputGetter):
          (KJS::HTMLElement::inputSetter):
          * khtml/ecma/kjs_html.h:
          (KJS::HTMLElement::):
          * khtml/html/html_formimpl.cpp:
          (DOM::HTMLInputElementImpl::init):
          (DOM::HTMLInputElementImpl::setIndeterminate):
          (DOM::HTMLInputElementImpl::preDispatchEventHandler):
          (DOM::HTMLInputElementImpl::postDispatchEventHandler):
          * khtml/html/html_formimpl.h:
          (DOM::HTMLInputElementImpl::isIndeterminate):
          (DOM::HTMLInputElementImpl::indeterminate):
          * khtml/rendering/render_theme.cpp:
          (khtml::RenderTheme::isIndeterminate):
          * khtml/rendering/render_theme.h:
          * khtml/rendering/render_theme_mac.mm:
          (khtml::RenderThemeMac::updateCheckedState):
          (khtml::RenderThemeMac::setCheckboxCellState):
          * khtml/xml/dom_nodeimpl.h:
          (DOM::NodeImpl::isIndeterminate):
  
  Revision  Changes    Path
  1.294     +48 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.293
  retrieving revision 1.294
  diff -u -r1.293 -r1.294
  --- ChangeLog	26 Oct 2005 07:23:36 -0000	1.293
  +++ ChangeLog	26 Oct 2005 19:44:01 -0000	1.294
  @@ -1,3 +1,51 @@
  +2005-10-26  David Hyatt  <hyatt at apple.com>
  +
  +	Add support for the indeterminate boolean for placing checkboxes
  +	into a mixed state.  This is a feature of WinIE.
  +
  +	Along with this feature, add support for the CSS3 :indeterminate
  +	selector, although one wonders how this could be part of the selectors spec
  +	when no DOM standard covers the ability to make a mixed checkbox
  +	in the first place.
  +
  +	This implementation may seem like it's overlooking some things, but it's not.
  +	Specifically "indeterminate" has no effect on form submission, it does not
  +	get cleared by a form reset, and the pre/post reversal code for undoing clicks
  +	only resets the state that changed in WinIE.  This is all bizarre behavior,
  +	but this is a WinIE extension, so we're going to match.
  +	
  +        Reviewed by mjs
  +
  +	fast/forms/indeterminate.html
  +
  +        * khtml/css/css_base.cpp:
  +        (CSSSelector::extractPseudoType):
  +        * khtml/css/css_base.h:
  +        (DOM::CSSSelector::):
  +        * khtml/css/cssstyleselector.cpp:
  +        (khtml::CSSStyleSelector::checkOneSelector):
  +        * khtml/ecma/kjs_html.cpp:
  +        (KJS::HTMLElement::inputGetter):
  +        (KJS::HTMLElement::inputSetter):
  +        * khtml/ecma/kjs_html.h:
  +        (KJS::HTMLElement::):
  +        * khtml/html/html_formimpl.cpp:
  +        (DOM::HTMLInputElementImpl::init):
  +        (DOM::HTMLInputElementImpl::setIndeterminate):
  +        (DOM::HTMLInputElementImpl::preDispatchEventHandler):
  +        (DOM::HTMLInputElementImpl::postDispatchEventHandler):
  +        * khtml/html/html_formimpl.h:
  +        (DOM::HTMLInputElementImpl::isIndeterminate):
  +        (DOM::HTMLInputElementImpl::indeterminate):
  +        * khtml/rendering/render_theme.cpp:
  +        (khtml::RenderTheme::isIndeterminate):
  +        * khtml/rendering/render_theme.h:
  +        * khtml/rendering/render_theme_mac.mm:
  +        (khtml::RenderThemeMac::updateCheckedState):
  +        (khtml::RenderThemeMac::setCheckboxCellState):
  +        * khtml/xml/dom_nodeimpl.h:
  +        (DOM::NodeImpl::isIndeterminate):
  +
   2005-10-26  Maciej Stachowiak  <mjs at apple.com>
   
           Re-landed fix for the following bug:
  
  
  
  1.23      +3 -0      WebCore/khtml/css/css_base.cpp
  
  Index: css_base.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_base.cpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- css_base.cpp	25 Oct 2005 00:07:45 -0000	1.22
  +++ css_base.cpp	26 Oct 2005 19:44:03 -0000	1.23
  @@ -153,6 +153,7 @@
       static AtomicString firstOfType("first-of-type");
       static AtomicString focus("focus");
       static AtomicString hover("hover");
  +    static AtomicString indeterminate("indeterminate");
       static AtomicString link("link");
       static AtomicString lang("lang(");
       static AtomicString lastChild("last-child");
  @@ -202,6 +203,8 @@
           _pseudoType = PseudoFocus;
       else if (value == hover)
           _pseudoType = PseudoHover;
  +    else if (value == indeterminate)
  +        _pseudoType = PseudoIndeterminate;
       else if (value == link)
           _pseudoType = PseudoLink;
       else if (value == lang)
  
  
  
  1.21      +1 -0      WebCore/khtml/css/css_base.h
  
  Index: css_base.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_base.h,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- css_base.h	25 Oct 2005 00:07:45 -0000	1.20
  +++ css_base.h	26 Oct 2005 19:44:04 -0000	1.21
  @@ -160,6 +160,7 @@
               PseudoChecked,
               PseudoEnabled,
               PseudoDisabled,
  +            PseudoIndeterminate,
               PseudoTarget,
               PseudoBefore,
               PseudoAfter,
  
  
  
  1.215     +8 -1      WebCore/khtml/css/cssstyleselector.cpp
  
  Index: cssstyleselector.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
  retrieving revision 1.214
  retrieving revision 1.215
  diff -u -r1.214 -r1.215
  --- cssstyleselector.cpp	24 Oct 2005 22:59:37 -0000	1.214
  +++ cssstyleselector.cpp	26 Oct 2005 19:44:04 -0000	1.215
  @@ -1431,9 +1431,16 @@
                       return !e->isEnabled();                    
                   break;
               case CSSSelector::PseudoChecked:
  -                if (e && e->isChecked())
  +                // Even though WinIE allows checked and indeterminate to co-exist, the CSS selector spec says that
  +                // you can't be both checked and indeterminate.  We will behave like WinIE behind the scenes and just
  +                // obey the CSS spec here in the test for matching the pseudo.
  +                if (e && e->isChecked() && !e->isIndeterminate())
                       return true;
                   break;
  +            case CSSSelector::PseudoIndeterminate:
  +	        if (e && e->isIndeterminate())
  +		    return true;
  +                break;
               case CSSSelector::PseudoRoot:
                   if (e == e->getDocument()->documentElement())
                       return true;
  
  
  
  1.142     +4 -1      WebCore/khtml/ecma/kjs_html.cpp
  
  Index: kjs_html.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.cpp,v
  retrieving revision 1.141
  retrieving revision 1.142
  diff -u -r1.141 -r1.142
  --- kjs_html.cpp	3 Oct 2005 21:12:13 -0000	1.141
  +++ kjs_html.cpp	26 Oct 2005 19:44:05 -0000	1.142
  @@ -891,7 +891,7 @@
     selected	KJS::HTMLElement::OptionSelected	DontDelete
     value		KJS::HTMLElement::OptionValue		DontDelete
   @end
  - at begin HTMLInputElementTable 23
  + at begin HTMLInputElementTable 24
     defaultValue	KJS::HTMLElement::InputDefaultValue	DontDelete
     defaultChecked KJS::HTMLElement::InputDefaultChecked	DontDelete
     form		KJS::HTMLElement::InputForm		DontDelete|ReadOnly
  @@ -901,6 +901,7 @@
     alt		KJS::HTMLElement::InputAlt		DontDelete
     checked	KJS::HTMLElement::InputChecked		DontDelete
     disabled	KJS::HTMLElement::InputDisabled		DontDelete
  +  indeterminate KJS::HTMLElement::InputIndeterminate    DontDelete
     maxLength	KJS::HTMLElement::InputMaxLength	DontDelete
     name		KJS::HTMLElement::InputName		DontDelete
     readOnly	KJS::HTMLElement::InputReadOnly		DontDelete
  @@ -1654,6 +1655,7 @@
           case InputAlt:             return String(input.alt());
           case InputChecked:         return Boolean(input.checked());
           case InputDisabled:        return Boolean(input.disabled());
  +        case InputIndeterminate:   return Boolean(input.indeterminate());
           case InputMaxLength:       return Number(input.maxLength());
           case InputName:            return String(input.name());
           case InputReadOnly:        return Boolean(input.readOnly());
  @@ -2739,6 +2741,7 @@
           case InputAlt:             { input.setAlt(str); return; }
           case InputChecked:         { input.setChecked(value->toBoolean(exec)); return; }
           case InputDisabled:        { input.setDisabled(value->toBoolean(exec)); return; }
  +        case InputIndeterminate:   { input.setIndeterminate(value->toBoolean(exec)); return; }
           case InputMaxLength:       { input.setMaxLength(value->toInt32(exec)); return; }
           case InputName:            { input.setName(str); return; }
           case InputReadOnly:        { input.setReadOnly(value->toBoolean(exec)); return; }
  
  
  
  1.57      +1 -1      WebCore/khtml/ecma/kjs_html.h
  
  Index: kjs_html.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.h,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- kjs_html.h	27 Sep 2005 22:37:04 -0000	1.56
  +++ kjs_html.h	26 Oct 2005 19:44:05 -0000	1.57
  @@ -227,7 +227,7 @@
              OptionLabel, OptionValue, InputBlur, InputReadOnly, InputAccept,
              InputSize, InputDefaultValue, InputTabIndex, InputValue, InputType,
              InputFocus, InputMaxLength, InputDefaultChecked, InputDisabled,
  -           InputChecked, InputForm, InputAccessKey, InputAlign, InputAlt,
  +           InputChecked, InputIndeterminate, InputForm, InputAccessKey, InputAlign, InputAlt,
              InputName, InputSrc, InputUseMap, InputSelect, InputClick,
              InputSelectionStart, InputSelectionEnd, InputSetSelectionRange,
              TextAreaAccessKey, TextAreaName, TextAreaDefaultValue, TextAreaSelect, TextAreaSetSelectionRange,
  
  
  
  1.200     +33 -14    WebCore/khtml/html/html_formimpl.cpp
  
  Index: html_formimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
  retrieving revision 1.199
  retrieving revision 1.200
  diff -u -r1.199 -r1.200
  --- html_formimpl.cpp	21 Oct 2005 21:27:45 -0000	1.199
  +++ html_formimpl.cpp	26 Oct 2005 19:44:06 -0000	1.200
  @@ -1372,7 +1372,8 @@
       m_checked = false;
       m_defaultChecked = false;
       m_useDefaultChecked = true;
  -    
  +    m_indeterminate = false;
  +
       m_haveType = false;
       m_activeSubmit = false;
       m_autocomplete = true;
  @@ -2170,6 +2171,19 @@
           theme()->stateChanged(renderer(), CheckedState);
   }
   
  +void HTMLInputElementImpl::setIndeterminate(bool _indeterminate)
  +{
  +    // Only checkboxes honor indeterminate.
  +    if (m_type != CHECKBOX || indeterminate() == _indeterminate)
  +        return;
  +
  +    m_indeterminate = _indeterminate;
  +
  +    setChanged();
  +
  +    if (renderer() && renderer()->style()->hasAppearance())
  +        theme()->stateChanged(renderer(), CheckedState);
  +}
   
   DOMString HTMLInputElementImpl::value() const
   {
  @@ -2297,12 +2311,16 @@
       if ((m_type == CHECKBOX || m_type == RADIO) && evt->isMouseEvent() && evt->type() == clickEvent && 
           static_cast<MouseEventImpl*>(evt)->button() == 0) {
           if (m_type == CHECKBOX) {
  -            // As a way to store the boolean, we return our node pointer if we were checked and 0 if we were unchecked.
  -            if (checked()) {
  -                ref();
  -                result = this;
  +            // As a way to store the state, we return 0 if we were unchecked, 1 if we were checked, and 2 for
  +            // indeterminate.
  +            if (indeterminate()) {
  +                result = (void*)0x2;
  +                setIndeterminate(false);
  +            } else {
  +                if (checked())
  +                    result = (void*)0x1;
  +                setChecked(!checked());
               }
  -            setChecked(!checked());
           } else {
               // For radio buttons, store the current selected radio object.
               if (name().isEmpty() || checked() || !form())
  @@ -2327,15 +2345,18 @@
   
   void HTMLInputElementImpl::postDispatchEventHandler(EventImpl *evt, void* data)
   {
  -    HTMLInputElementImpl* input = static_cast<HTMLInputElementImpl*>(data);
  -
       if ((m_type == CHECKBOX || m_type == RADIO) && evt->isMouseEvent() && evt->type() == clickEvent && 
           static_cast<MouseEventImpl*>(evt)->button() == 0) {
           if (m_type == CHECKBOX) {
               // Reverse the checking we did in preDispatch.
  -            if (evt->defaultPrevented() || evt->defaultHandled())
  -                setChecked(input);
  -        } else if (input) {
  +            if (evt->defaultPrevented() || evt->defaultHandled()) {
  +                if (data == (void*)0x2)
  +                    setIndeterminate(true);
  +                else
  +                    setChecked(data);
  +            }
  +        } else if (data) {
  +            HTMLInputElementImpl* input = static_cast<HTMLInputElementImpl*>(data);
               if (evt->defaultPrevented() || evt->defaultHandled()) {
                   // Restore the original selected radio button if possible.
                   // Make sure it is still a radio button and only do the restoration if it still
  @@ -2346,11 +2367,9 @@
                       input->setChecked(true);
                   }
               }
  +            input->deref();
           }
       }
  -    
  -    if (input)
  -        input->deref();
   }
   
   void HTMLInputElementImpl::defaultEventHandler(EventImpl *evt)
  
  
  
  1.92      +5 -1      WebCore/khtml/html/html_formimpl.h
  
  Index: html_formimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.h,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- html_formimpl.h	21 Oct 2005 21:27:45 -0000	1.91
  +++ html_formimpl.h	26 Oct 2005 19:44:06 -0000	1.92
  @@ -347,11 +347,14 @@
       bool autoComplete() const { return m_autocomplete; }
   
       virtual bool isChecked() const { return checked(); }
  -    
  +    virtual bool isIndeterminate() const { return indeterminate(); }
  +
       bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; }
   
       bool checked() const { return m_checked; }
       void setChecked(bool);
  +    bool indeterminate() const { return m_indeterminate; }
  +    void setIndeterminate(bool);
       int maxLength() const { return m_maxLen; }
       int size() const { return m_size; }
       DOMString type() const;
  @@ -465,6 +468,7 @@
       bool m_checked : 1;
       bool m_defaultChecked : 1;
       bool m_useDefaultChecked : 1;
  +    bool m_indeterminate : 1;
       bool m_haveType : 1;
       bool m_activeSubmit : 1;
       bool m_autocomplete : 1;
  
  
  
  1.14      +7 -0      WebCore/khtml/rendering/render_theme.cpp
  
  Index: render_theme.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- render_theme.cpp	22 Oct 2005 18:19:27 -0000	1.13
  +++ render_theme.cpp	26 Oct 2005 19:44:07 -0000	1.14
  @@ -123,6 +123,13 @@
       return o->element()->isChecked();
   }
   
  +bool RenderTheme::isIndeterminate(const RenderObject* o) const
  +{
  +    if (!o->element())
  +        return false;
  +    return o->element()->isIndeterminate();
  +}
  +
   bool RenderTheme::isEnabled(const RenderObject* o) const
   {
       if (!o->element())
  
  
  
  1.12      +1 -0      WebCore/khtml/rendering/render_theme.h
  
  Index: render_theme.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- render_theme.h	22 Oct 2005 18:19:27 -0000	1.11
  +++ render_theme.h	26 Oct 2005 19:44:07 -0000	1.12
  @@ -85,6 +85,7 @@
   protected:
       // Methods for state querying
       bool isChecked(const RenderObject* o) const;
  +    bool isIndeterminate(const RenderObject* o) const;
       bool isEnabled(const RenderObject* o) const;
       bool isFocused(const RenderObject* o) const;
       bool isPressed(const RenderObject* o) const;
  
  
  
  1.13      +11 -1     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- render_theme_mac.mm	25 Oct 2005 20:54:28 -0000	1.12
  +++ render_theme_mac.mm	26 Oct 2005 19:44:07 -0000	1.13
  @@ -110,8 +110,16 @@
   
   void RenderThemeMac::updateCheckedState(NSCell* cell, const RenderObject* o)
   {
  -    bool oldChecked = [cell state] == NSOnState;
  +    bool oldIndeterminate = [cell state] == NSMixedState;
  +    bool indeterminate = isIndeterminate(o);
       bool checked = isChecked(o);
  +    
  +    if (oldIndeterminate != indeterminate) {
  +        [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSOffState)];
  +        return;
  +    }
  +
  +    bool oldChecked = [cell state] == NSOnState;
       if (checked != oldChecked)
           [cell setState:checked ? NSOnState : NSOffState];
   }
  @@ -278,6 +286,8 @@
           checkbox = [[NSButtonCell alloc] init];
           [checkbox setButtonType:NSSwitchButton];
           [checkbox setTitle:nil];
  +        [checkbox setAllowsMixedState:YES];
  +        
       }
       
       // Set the control size based off the rectangle we're painting into.
  
  
  
  1.109     +1 -0      WebCore/khtml/xml/dom_nodeimpl.h
  
  Index: dom_nodeimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_nodeimpl.h,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- dom_nodeimpl.h	26 Oct 2005 04:55:09 -0000	1.108
  +++ dom_nodeimpl.h	26 Oct 2005 19:44:08 -0000	1.109
  @@ -249,6 +249,7 @@
       virtual bool isControl() const { return false; } // Eventually the notion of what is a control will be extensible.
       virtual bool isEnabled() const { return true; }
       virtual bool isChecked() const { return false; }
  +    virtual bool isIndeterminate() const { return false; }
   
       virtual bool isContentEditable() const;
       virtual QRect getRect() const;
  
  
  



More information about the webkit-changes mailing list