Change Element::isReadOnlyFormControl to Element::shouldMatchReadOnlySelector/shouldM...
authoryosin@chromium.org <yosin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jul 2012 07:58:47 +0000 (07:58 +0000)
committeryosin@chromium.org <yosin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jul 2012 07:58:47 +0000 (07:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92602

Reviewed by Kent Tamura.

This patch replaces Element::isReadOnlyFormControl() by
Element::shouldMatchReadOnlySelector/shouldMatchReadOnlySelector or
HTMLFormControlElement::readOnly() to make intention of functions
self descriptive.

No new tests. This patch doesn't change behavior.

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOneSelector): Replaced isReadOnlyFormControl() by shouldMatchReadOnlySelector() for :read-only pseudo class, and replaced isReadOnlyFormControl() by shouldMatchReadOnlySelector() for :read-only pseudo class.
* dom/Element.cpp:
(WebCore::Element::shouldMatchReadOnlySelector): Added for default implementation.
(WebCore::Element::shouldMatchReadWriteSelector): for default implementation.
* dom/Element.h:
(Element): Removed isReadOnlyFormControl() and added shouldMatchReadOnlySelector and shouldMatchReadWriteSelector.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::shouldMatchReadOnlySelector): Added.
(WebCore::HTMLFormControlElement::shouldMatchReadWriteSelector): Added.
* html/HTMLFormControlElement.h:
(HTMLFormControlElement): Removed isReadOnlyFormControl() and added shouldMatchReadOnlySelector and shouldMatchReadWriteSelector.
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::shouldMatchReadOnlySelector): Added.
(WebCore::SliderThumbElement::shouldMatchReadWriteSelector): Added.
(WebCore::SliderThumbElement::willRespondToMouseMoveEvents): Replaced isReadOnlyFormControl() by readOnly().
(WebCore::SliderThumbElement::willRespondToMouseClickEvents): ditto.
(SliderThumbElement):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldCancelButtonElement::willRespondToMouseClickEvents): Replaced isReadOnlyFormControl() by readOnly().
(WebCore::SpinButtonElement::willRespondToMouseMoveEvents): ditto.
(WebCore::SpinButtonElement::willRespondToMouseClickEvents): ditto.
(WebCore::SpinButtonElement::shouldMatchReadOnlySelector): Added.
(WebCore::SpinButtonElement::shouldMatchReadWriteSelector): Added.
(WebCore::InputFieldSpeechButtonElement::willRespondToMouseClickEvents): Replaced isReadOnlyFormControl() by readOnly().
* html/shadow/TextControlInnerElements.h:
(SpinButtonElement): Removed isReadOnlyFormControl() and added shouldMatchReadOnlySelector and shouldMatchReadWriteSelector.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isReadOnlyControl): Replaced isReadOnlyControl() by shouldMatchReadOnlySelector().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124180 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/shadow/SliderThumbElement.cpp
Source/WebCore/html/shadow/SliderThumbElement.h
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/html/shadow/TextControlInnerElements.h
Source/WebCore/rendering/RenderTheme.cpp

index 72a0ab6..9240fab 100644 (file)
@@ -1,3 +1,47 @@
+2012-07-31  Yoshifumi Inoue  <yosin@chromium.org>
+
+        Change Element::isReadOnlyFormControl to Element::shouldMatchReadOnlySelector/shouldMatchReadWriteSelector or HTMLFormControlElement::readOnly
+        https://bugs.webkit.org/show_bug.cgi?id=92602
+
+        Reviewed by Kent Tamura.
+
+        This patch replaces Element::isReadOnlyFormControl() by
+        Element::shouldMatchReadOnlySelector/shouldMatchReadOnlySelector or
+        HTMLFormControlElement::readOnly() to make intention of functions
+        self descriptive.
+
+        No new tests. This patch doesn't change behavior.
+
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOneSelector): Replaced isReadOnlyFormControl() by shouldMatchReadOnlySelector() for :read-only pseudo class, and replaced isReadOnlyFormControl() by shouldMatchReadOnlySelector() for :read-only pseudo class.
+        * dom/Element.cpp:
+        (WebCore::Element::shouldMatchReadOnlySelector): Added for default implementation.
+        (WebCore::Element::shouldMatchReadWriteSelector): for default implementation.
+        * dom/Element.h:
+        (Element): Removed isReadOnlyFormControl() and added shouldMatchReadOnlySelector and shouldMatchReadWriteSelector.
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::shouldMatchReadOnlySelector): Added.
+        (WebCore::HTMLFormControlElement::shouldMatchReadWriteSelector): Added.
+        * html/HTMLFormControlElement.h:
+        (HTMLFormControlElement): Removed isReadOnlyFormControl() and added shouldMatchReadOnlySelector and shouldMatchReadWriteSelector.
+        * html/shadow/SliderThumbElement.cpp:
+        (WebCore::SliderThumbElement::shouldMatchReadOnlySelector): Added.
+        (WebCore::SliderThumbElement::shouldMatchReadWriteSelector): Added.
+        (WebCore::SliderThumbElement::willRespondToMouseMoveEvents): Replaced isReadOnlyFormControl() by readOnly().
+        (WebCore::SliderThumbElement::willRespondToMouseClickEvents): ditto.
+        (SliderThumbElement):
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::SearchFieldCancelButtonElement::willRespondToMouseClickEvents): Replaced isReadOnlyFormControl() by readOnly().
+        (WebCore::SpinButtonElement::willRespondToMouseMoveEvents): ditto.
+        (WebCore::SpinButtonElement::willRespondToMouseClickEvents): ditto.
+        (WebCore::SpinButtonElement::shouldMatchReadOnlySelector): Added.
+        (WebCore::SpinButtonElement::shouldMatchReadWriteSelector): Added.
+        (WebCore::InputFieldSpeechButtonElement::willRespondToMouseClickEvents): Replaced isReadOnlyFormControl() by readOnly().
+        * html/shadow/TextControlInnerElements.h:
+        (SpinButtonElement): Removed isReadOnlyFormControl() and added shouldMatchReadOnlySelector and shouldMatchReadWriteSelector.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::isReadOnlyControl): Replaced isReadOnlyControl() by shouldMatchReadOnlySelector().
+
 2012-07-31  Xingnan Wang  <xingnan.wang@intel.com>
 
         IndexedDB: Size the Vector in encodeInt/encodeVarInt/encodeString
index ef6ea82..9a32d60 100644 (file)
@@ -1066,11 +1066,11 @@ bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context, P
         case CSSSelector::PseudoReadOnly:
             if (!element || !element->isFormControlElement())
                 return false;
-            return element->isTextFormControl() && element->isReadOnlyFormControl();
+            return element->isTextFormControl() && element->shouldMatchReadOnlySelector();
         case CSSSelector::PseudoReadWrite:
             if (!element || !element->isFormControlElement())
                 return false;
-            return element->isTextFormControl() && !element->isReadOnlyFormControl();
+            return element->isTextFormControl() && element->shouldMatchReadWriteSelector();
         case CSSSelector::PseudoOptional:
             return element && element->isOptionalFormControl();
         case CSSSelector::PseudoRequired:
index c323fa1..294b483 100644 (file)
@@ -1783,6 +1783,16 @@ unsigned Element::childElementCount() const
     return count;
 }
 
+bool Element::shouldMatchReadOnlySelector() const
+{
+    return false;
+}
+
+bool Element::shouldMatchReadWriteSelector() const
+{
+    return false;
+}
+
 bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec)
 {
     if (selector.isEmpty()) {
index 0159021..3059723 100644 (file)
@@ -350,6 +350,8 @@ public:
     Element* nextElementSibling() const;
     unsigned childElementCount() const;
 
+    virtual bool shouldMatchReadOnlySelector() const;
+    virtual bool shouldMatchReadWriteSelector() const;
     bool webkitMatchesSelector(const String& selectors, ExceptionCode&);
 
     DOMTokenList* classList();
@@ -373,7 +375,6 @@ public:
 
     virtual bool isFormControlElement() const { return false; }
     virtual bool isEnabledFormControl() const { return true; }
-    virtual bool isReadOnlyFormControl() const { return false; }
     virtual bool isSpinButtonElement() const { return false; }
     virtual bool isTextFormControl() const { return false; }
     virtual bool isOptionalFormControl() const { return false; }
index d52d0ba..2d47ac8 100644 (file)
@@ -482,6 +482,16 @@ void HTMLFormControlElement::setCustomValidity(const String& error)
     setNeedsValidityCheck();
 }
 
+bool HTMLFormControlElement::shouldMatchReadOnlySelector() const
+{
+    return readOnly();
+}
+
+bool HTMLFormControlElement::shouldMatchReadWriteSelector() const
+{
+    return !readOnly();
+}
+
 bool HTMLFormControlElement::validationMessageShadowTreeContains(Node* node) const
 {
     return m_validationMessage && m_validationMessage->shadowTreeContains(node);
index b132cbe..d129bc2 100644 (file)
@@ -81,7 +81,8 @@ public:
 
     virtual const AtomicString& formControlType() const OVERRIDE = 0;
     virtual bool isEnabledFormControl() const { return !disabled(); }
-    virtual bool isReadOnlyFormControl() const { return readOnly(); }
+    virtual bool shouldMatchReadOnlySelector() const OVERRIDE;
+    virtual bool shouldMatchReadWriteSelector() const OVERRIDE;
 
     virtual bool canTriggerImplicitSubmission() const { return false; }
 
index b020b38..36221dd 100644 (file)
@@ -214,9 +214,14 @@ bool SliderThumbElement::isEnabledFormControl() const
     return hostInput()->isEnabledFormControl();
 }
 
-bool SliderThumbElement::isReadOnlyFormControl() const
+bool SliderThumbElement::shouldMatchReadOnlySelector() const
 {
-    return hostInput()->isReadOnlyFormControl();
+    return hostInput()->shouldMatchReadOnlySelector();
+}
+
+bool SliderThumbElement::shouldMatchReadWriteSelector() const
+{
+    return hostInput()->shouldMatchReadWriteSelector();
 }
 
 Node* SliderThumbElement::focusDelegate()
@@ -334,7 +339,7 @@ void SliderThumbElement::defaultEventHandler(Event* event)
 bool SliderThumbElement::willRespondToMouseMoveEvents()
 {
     const HTMLInputElement* input = hostInput();
-    if (input && !input->isReadOnlyFormControl() && input->isEnabledFormControl() && m_inDragMode)
+    if (input && !input->readOnly() && input->isEnabledFormControl() && m_inDragMode)
         return true;
 
     return HTMLDivElement::willRespondToMouseMoveEvents();
@@ -343,7 +348,7 @@ bool SliderThumbElement::willRespondToMouseMoveEvents()
 bool SliderThumbElement::willRespondToMouseClickEvents()
 {
     const HTMLInputElement* input = hostInput();
-    if (input && !input->isReadOnlyFormControl() && input->isEnabledFormControl())
+    if (input && !input->readOnly() && input->isEnabledFormControl())
         return true;
 
     return HTMLDivElement::willRespondToMouseClickEvents();
index 11d3503..04e41c7 100644 (file)
@@ -66,7 +66,8 @@ private:
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren();
     virtual bool isEnabledFormControl() const;
-    virtual bool isReadOnlyFormControl() const;
+    virtual bool shouldMatchReadOnlySelector() const OVERRIDE;
+    virtual bool shouldMatchReadWriteSelector() const OVERRIDE;
     virtual Node* focusDelegate();
     void startDragging();
     void stopDragging();
index 0fd41c6..e06d56f 100644 (file)
@@ -242,7 +242,7 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
 bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents()
 {
     const HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost());
-    if (!input->disabled() && !input->isReadOnlyFormControl())
+    if (!input->disabled() && !input->readOnly())
         return true;
 
     return HTMLDivElement::willRespondToMouseClickEvents();
@@ -345,7 +345,7 @@ void SpinButtonElement::defaultEventHandler(Event* event)
 bool SpinButtonElement::willRespondToMouseMoveEvents()
 {
     const HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost());
-    if (renderBox() && !input->disabled() && !input->isReadOnlyFormControl())
+    if (renderBox() && !input->disabled() && !input->readOnly())
         return true;
 
     return HTMLDivElement::willRespondToMouseMoveEvents();
@@ -354,7 +354,7 @@ bool SpinButtonElement::willRespondToMouseMoveEvents()
 bool SpinButtonElement::willRespondToMouseClickEvents()
 {
     const HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost());
-    if (renderBox() && !input->disabled() && !input->isReadOnlyFormControl())
+    if (renderBox() && !input->disabled() && !input->readOnly())
         return true;
 
     return HTMLDivElement::willRespondToMouseClickEvents();
@@ -382,6 +382,16 @@ void SpinButtonElement::releaseCapture()
     }
 }
 
+bool SpinButtonElement::shouldMatchReadOnlySelector() const
+{
+    return shadowHost()->shouldMatchReadOnlySelector();
+}
+
+bool SpinButtonElement::shouldMatchReadWriteSelector() const
+{
+    return shadowHost()->shouldMatchReadWriteSelector();
+}
+
 void SpinButtonElement::startRepeatingTimer()
 {
     m_pressStartingState = m_upDownState;
@@ -514,7 +524,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
 bool InputFieldSpeechButtonElement::willRespondToMouseClickEvents()
 {
     const HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost());
-    if (!input->disabled() && !input->isReadOnlyFormControl())
+    if (!input->disabled() && !input->readOnly())
         return true;
 
     return HTMLDivElement::willRespondToMouseClickEvents();
index 2e89096..6336dcb 100644 (file)
@@ -125,7 +125,8 @@ private:
     virtual void detach();
     virtual bool isSpinButtonElement() const { return true; }
     virtual bool isEnabledFormControl() const { return shadowHost()->isEnabledFormControl(); }
-    virtual bool isReadOnlyFormControl() const { return shadowHost()->isReadOnlyFormControl(); }
+    virtual bool shouldMatchReadOnlySelector() const OVERRIDE;
+    virtual bool shouldMatchReadWriteSelector() const OVERRIDE;
     virtual void defaultEventHandler(Event*);
     void doStepAction(int);
     void startRepeatingTimer();
index f166172..93b7b87 100644 (file)
@@ -828,7 +828,7 @@ bool RenderTheme::isReadOnlyControl(const RenderObject* o) const
     Node* node = o->node();
     if (!node || !node->isElementNode())
         return false;
-    return static_cast<Element*>(node)->isReadOnlyFormControl();
+    return static_cast<Element*>(node)->shouldMatchReadOnlySelector();
 }
 
 bool RenderTheme::isHovered(const RenderObject* o) const