Title: [141086] trunk/Source/WebCore
Revision
141086
Author
[email protected]
Date
2013-01-29 02:01:24 -0800 (Tue, 29 Jan 2013)

Log Message

FeatureObserver: Input types are counted unexpectedly in a page with Modernizr
https://bugs.webkit.org/show_bug.cgi?id=108141

Reviewed by Kentaro Hara.

We don't want to record input type instantiation by Modernizr. Modernizr
creates input elements with these types, append it to document.body, and
render it with visibility:hidden. So, we record input types only when
they are attached without visibility:hidden.

No new tests. FeatureObserver is not testable by layout test.

* html/InputType.cpp:
(WebCore::InputType::create): Remove FeatureObserver::observe
callsites. They are moved to TextInputType::attach.
(WebCore::InputType::observeFeatureIfVisible):
Added. A helper for attach().
* html/InputType.h:
(InputType): Add observeFeatureIfVisible.

* html/ColorInputType.cpp:
(WebCore::ColorInputType::create):
Remove a FeatureObserver::observe callsite.
(WebCore::ColorInputType::attach):
Calls FetureObserver through InputType::observeFeatureIfVisible.
* html/ColorInputType.h:
(ColorInputType): Declare attach.
* html/DateInputType.cpp: Ditto.
* html/DateInputType.h: Ditto.
* html/DateTimeInputType.cpp: Ditto.
* html/DateTimeInputType.h: Ditto.
* html/DateTimeLocalInputType.cpp: Ditto.
* html/DateTimeLocalInputType.h: Ditto.
* html/MonthInputType.cpp: Ditto.
* html/MonthInputType.h: Ditto.
* html/RangeInputType.cpp: Ditt
* html/RangeInputType.h: Ditto.
* html/TimeInputType.cpp: Ditto.
* html/TimeInputType.h: Ditto.
* html/WeekInputType.cpp: Ditto.
* html/WeekInputType.h: Ditto.

* html/TextFieldInputType.h:
(TextFieldInputType):
Make attach protected in order that sub classes can call it.
* html/EmailInputType.cpp:
(WebCore::EmailInputType::create):
Remove a FeatureObserver::observe callsite.
(WebCore::EmailInputType::attach): Calls FetureObserver through
InputType::observeFeatureIfVisible after TextFieldInptuType::attach.
* html/EmailInputType.h:
(EmailInputType):Declare attach.
* html/NumberInputType.cpp: Ditto.
* html/NumberInputType.h: Ditto.
* html/SearchInputType.cpp: Ditto.
* html/SearchInputType.h: Ditto.
* html/TelephoneInputType.cpp: Ditto.
* html/TelephoneInputType.h: Ditto.
* html/URLInputType.cpp: Ditto.
* html/URLInputType.h: Ditto.

* html/TextInputType.cpp:
(WebCore::TextInputType::attach):
Move the code for type fallback from InputType::create.
* html/TextInputType.h:
(TextInputType): Declare attach.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141085 => 141086)


--- trunk/Source/WebCore/ChangeLog	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/ChangeLog	2013-01-29 10:01:24 UTC (rev 141086)
@@ -1,3 +1,72 @@
+2013-01-29  Kent Tamura  <[email protected]>
+
+        FeatureObserver: Input types are counted unexpectedly in a page with Modernizr
+        https://bugs.webkit.org/show_bug.cgi?id=108141
+
+        Reviewed by Kentaro Hara.
+
+        We don't want to record input type instantiation by Modernizr. Modernizr
+        creates input elements with these types, append it to document.body, and
+        render it with visibility:hidden. So, we record input types only when
+        they are attached without visibility:hidden.
+
+        No new tests. FeatureObserver is not testable by layout test.
+
+        * html/InputType.cpp:
+        (WebCore::InputType::create): Remove FeatureObserver::observe
+        callsites. They are moved to TextInputType::attach.
+        (WebCore::InputType::observeFeatureIfVisible):
+        Added. A helper for attach().
+        * html/InputType.h:
+        (InputType): Add observeFeatureIfVisible.
+
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::create):
+        Remove a FeatureObserver::observe callsite.
+        (WebCore::ColorInputType::attach):
+        Calls FetureObserver through InputType::observeFeatureIfVisible.
+        * html/ColorInputType.h:
+        (ColorInputType): Declare attach.
+        * html/DateInputType.cpp: Ditto.
+        * html/DateInputType.h: Ditto.
+        * html/DateTimeInputType.cpp: Ditto.
+        * html/DateTimeInputType.h: Ditto.
+        * html/DateTimeLocalInputType.cpp: Ditto.
+        * html/DateTimeLocalInputType.h: Ditto.
+        * html/MonthInputType.cpp: Ditto.
+        * html/MonthInputType.h: Ditto.
+        * html/RangeInputType.cpp: Ditt
+        * html/RangeInputType.h: Ditto.
+        * html/TimeInputType.cpp: Ditto.
+        * html/TimeInputType.h: Ditto.
+        * html/WeekInputType.cpp: Ditto.
+        * html/WeekInputType.h: Ditto.
+
+        * html/TextFieldInputType.h:
+        (TextFieldInputType):
+        Make attach protected in order that sub classes can call it.
+        * html/EmailInputType.cpp:
+        (WebCore::EmailInputType::create):
+        Remove a FeatureObserver::observe callsite.
+        (WebCore::EmailInputType::attach): Calls FetureObserver through
+        InputType::observeFeatureIfVisible after TextFieldInptuType::attach.
+        * html/EmailInputType.h:
+        (EmailInputType):Declare attach.
+        * html/NumberInputType.cpp: Ditto.
+        * html/NumberInputType.h: Ditto.
+        * html/SearchInputType.cpp: Ditto.
+        * html/SearchInputType.h: Ditto.
+        * html/TelephoneInputType.cpp: Ditto.
+        * html/TelephoneInputType.h: Ditto.
+        * html/URLInputType.cpp: Ditto.
+        * html/URLInputType.h: Ditto.
+
+        * html/TextInputType.cpp:
+        (WebCore::TextInputType::attach):
+        Move the code for type fallback from InputType::create.
+        * html/TextInputType.h:
+        (TextInputType): Declare attach.
+
 2013-01-29  Michael BrĂ¼ning  <[email protected]>
 
         [Qt][WK1] Reflect recursion limit and loop checks also for list conversions.

Modified: trunk/Source/WebCore/html/ColorInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/ColorInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/ColorInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -35,7 +35,6 @@
 #include "Chrome.h"
 #include "Color.h"
 #include "ElementShadow.h"
-#include "FeatureObserver.h"
 #include "HTMLDataListElement.h"
 #include "HTMLDivElement.h"
 #include "HTMLInputElement.h"
@@ -72,7 +71,6 @@
 
 PassOwnPtr<InputType> ColorInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeColor);
     return adoptPtr(new ColorInputType(element));
 }
 
@@ -81,6 +79,11 @@
     endColorChooser();
 }
 
+void ColorInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeColor);
+}
+
 bool ColorInputType::isColorControl() const
 {
     return true;

Modified: trunk/Source/WebCore/html/ColorInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/ColorInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/ColorInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -53,6 +53,7 @@
 
 private:
     ColorInputType(HTMLInputElement* element) : BaseClickableWithKeyInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual bool isColorControl() const OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual bool supportsRequired() const OVERRIDE;

Modified: trunk/Source/WebCore/html/DateInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/DateInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/DateInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -34,7 +34,6 @@
 #if ENABLE(INPUT_TYPE_DATE)
 #include "DateComponents.h"
 #include "DateTimeFieldsState.h"
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -59,10 +58,14 @@
 
 PassOwnPtr<InputType> DateInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeDate);
     return adoptPtr(new DateInputType(element));
 }
 
+void DateInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeDate);
+}
+
 const AtomicString& DateInputType::formControlType() const
 {
     return InputTypeNames::date();

Modified: trunk/Source/WebCore/html/DateInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/DateInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/DateInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -52,6 +52,7 @@
 
 private:
     DateInputType(HTMLInputElement*);
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual StepRange createStepRange(AnyStepHandling) const OVERRIDE;

Modified: trunk/Source/WebCore/html/DateTimeInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/DateTimeInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/DateTimeInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -32,7 +32,6 @@
 #include "DateTimeInputType.h"
 
 #include "DateComponents.h"
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -59,10 +58,14 @@
 
 PassOwnPtr<InputType> DateTimeInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeDateTime);
     return adoptPtr(new DateTimeInputType(element));
 }
 
+void DateTimeInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeDateTime);
+}
+
 const AtomicString& DateTimeInputType::formControlType() const
 {
     return InputTypeNames::datetime();

Modified: trunk/Source/WebCore/html/DateTimeInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/DateTimeInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/DateTimeInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -51,6 +51,7 @@
 
 private:
     DateTimeInputType(HTMLInputElement* element) : BaseDateTimeInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual StepRange createStepRange(AnyStepHandling) const OVERRIDE;

Modified: trunk/Source/WebCore/html/DateTimeLocalInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/DateTimeLocalInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/DateTimeLocalInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -32,7 +32,6 @@
 #include "DateTimeLocalInputType.h"
 
 #include "DateComponents.h"
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -58,10 +57,14 @@
 
 PassOwnPtr<InputType> DateTimeLocalInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeDateTimeLocal);
     return adoptPtr(new DateTimeLocalInputType(element));
 }
 
+void DateTimeLocalInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeDateTimeLocal);
+}
+
 const AtomicString& DateTimeLocalInputType::formControlType() const
 {
     return InputTypeNames::datetimelocal();

Modified: trunk/Source/WebCore/html/DateTimeLocalInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/DateTimeLocalInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/DateTimeLocalInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -49,6 +49,7 @@
 
 private:
     DateTimeLocalInputType(HTMLInputElement* element) : BaseDateTimeLocalInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual double valueAsDate() const OVERRIDE;

Modified: trunk/Source/WebCore/html/EmailInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/EmailInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/EmailInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -24,7 +24,6 @@
 #include "config.h"
 #include "EmailInputType.h"
 
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLParserIdioms.h"
 #include "InputTypeNames.h"
@@ -56,10 +55,15 @@
 
 PassOwnPtr<InputType> EmailInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeEmail);
     return adoptPtr(new EmailInputType(element));
 }
 
+void EmailInputType::attach()
+{
+    TextFieldInputType::attach();
+    observeFeatureIfVisible(FeatureObserver::InputTypeEmail);
+}
+
 const AtomicString& EmailInputType::formControlType() const
 {
     return InputTypeNames::email();

Modified: trunk/Source/WebCore/html/EmailInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/EmailInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/EmailInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -41,6 +41,7 @@
 
 private:
     EmailInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual bool typeMismatchFor(const String&) const OVERRIDE;
     virtual bool typeMismatch() const OVERRIDE;

Modified: trunk/Source/WebCore/html/InputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/InputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/InputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -55,6 +55,7 @@
 #include "KeyboardEvent.h"
 #include "LocalizedStrings.h"
 #include "MonthInputType.h"
+#include "NodeRenderStyle.h"
 #include "NumberInputType.h"
 #include "Page.h"
 #include "PasswordInputType.h"
@@ -140,13 +141,8 @@
 {
     static const InputTypeFactoryMap* factoryMap = createInputTypeFactoryMap().leakPtr();
     PassOwnPtr<InputType> (*factory)(HTMLInputElement*) = typeName.isEmpty() ? 0 : factoryMap->get(typeName);
-    if (!factory) {
+    if (!factory)
         factory = TextInputType::create;
-        if (typeName == InputTypeNames::datetime())
-            FeatureObserver::observe(element->document(), FeatureObserver::InputTypeDateTimeFallback);
-        else if (typeName == InputTypeNames::week())
-            FeatureObserver::observe(element->document(), FeatureObserver::InputTypeWeekFallback);
-    }
     return factory(element);
 }
 
@@ -1134,4 +1130,12 @@
     }
 }
 
+void InputType::observeFeatureIfVisible(FeatureObserver::Feature feature) const
+{
+    if (RenderStyle* style = element()->renderStyle()) {
+        if (style->visibility() != HIDDEN)
+            FeatureObserver::observe(element()->document(), feature);
+    }
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/InputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/InputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/InputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -33,6 +33,7 @@
 #ifndef InputType_h
 #define InputType_h
 
+#include "FeatureObserver.h"
 #include "HTMLTextFormControlElement.h"
 #include "StepRange.h"
 #include <wtf/Forward.h>
@@ -313,6 +314,7 @@
     HTMLInputElement* element() const { return m_element; }
     Chrome* chrome() const;
     Decimal parseToNumberOrNaN(const String&) const;
+    void observeFeatureIfVisible(FeatureObserver::Feature) const;
 
 private:
     // Helper for stepUp()/stepDown(). Adds step value * count to the current value.

Modified: trunk/Source/WebCore/html/MonthInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/MonthInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/MonthInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -32,7 +32,6 @@
 #include "MonthInputType.h"
 
 #include "DateComponents.h"
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -60,10 +59,14 @@
 
 PassOwnPtr<InputType> MonthInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeMonth);
     return adoptPtr(new MonthInputType(element));
 }
 
+void MonthInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeMonth);
+}
+
 const AtomicString& MonthInputType::formControlType() const
 {
     return InputTypeNames::month();

Modified: trunk/Source/WebCore/html/MonthInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/MonthInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/MonthInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -49,6 +49,7 @@
 
 private:
     MonthInputType(HTMLInputElement* element) : BaseMonthInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual double valueAsDate() const OVERRIDE;

Modified: trunk/Source/WebCore/html/NumberInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/NumberInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/NumberInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -34,7 +34,6 @@
 
 #include "BeforeTextInsertedEvent.h"
 #include "ExceptionCode.h"
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
@@ -99,10 +98,15 @@
 
 PassOwnPtr<InputType> NumberInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeNumber);
     return adoptPtr(new NumberInputType(element));
 }
 
+void NumberInputType::attach()
+{
+    TextFieldInputType::attach();
+    observeFeatureIfVisible(FeatureObserver::InputTypeNumber);
+}
+
 const AtomicString& NumberInputType::formControlType() const
 {
     return InputTypeNames::number();

Modified: trunk/Source/WebCore/html/NumberInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/NumberInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/NumberInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -41,6 +41,7 @@
 
 private:
     NumberInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
     virtual double valueAsDouble() const OVERRIDE;

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -34,7 +34,6 @@
 
 #include "AXObjectCache.h"
 #include "ElementShadow.h"
-#include "FeatureObserver.h"
 #include "HTMLDivElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
@@ -82,7 +81,6 @@
 
 PassOwnPtr<InputType> RangeInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeRange);
     return adoptPtr(new RangeInputType(element));
 }
 
@@ -94,6 +92,11 @@
 {
 }
 
+void RangeInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeRange);
+}
+
 bool RangeInputType::isRangeControl() const
 {
     return true;

Modified: trunk/Source/WebCore/html/RangeInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/RangeInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/RangeInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -43,6 +43,7 @@
 
 private:
     RangeInputType(HTMLInputElement*);
+    virtual void attach() OVERRIDE;
     virtual bool isRangeControl() const OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual double valueAsDouble() const OVERRIDE;

Modified: trunk/Source/WebCore/html/SearchInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/SearchInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/SearchInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -31,7 +31,6 @@
 #include "config.h"
 #include "SearchInputType.h"
 
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -55,10 +54,15 @@
 
 PassOwnPtr<InputType> SearchInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeSearch);
     return adoptPtr(new SearchInputType(element));
 }
 
+void SearchInputType::attach()
+{
+    TextFieldInputType::attach();
+    observeFeatureIfVisible(FeatureObserver::InputTypeSearch);
+}
+
 void SearchInputType::addSearchResult()
 {
     if (RenderObject* renderer = element()->renderer())

Modified: trunk/Source/WebCore/html/SearchInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/SearchInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/SearchInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -47,6 +47,7 @@
 
 private:
     SearchInputType(HTMLInputElement*);
+    virtual void attach() OVERRIDE;
     virtual void addSearchResult() OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;

Modified: trunk/Source/WebCore/html/TelephoneInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/TelephoneInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/TelephoneInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -31,7 +31,6 @@
 #include "config.h"
 #include "TelephoneInputType.h"
 
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "InputTypeNames.h"
 #include <wtf/PassOwnPtr.h>
@@ -40,10 +39,15 @@
 
 PassOwnPtr<InputType> TelephoneInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeTel);
     return adoptPtr(new TelephoneInputType(element));
 }
 
+void TelephoneInputType::attach()
+{
+    TextFieldInputType::attach();
+    observeFeatureIfVisible(FeatureObserver::InputTypeTel);
+}
+
 const AtomicString& TelephoneInputType::formControlType() const
 {
     return InputTypeNames::telephone();

Modified: trunk/Source/WebCore/html/TelephoneInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/TelephoneInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/TelephoneInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -41,6 +41,7 @@
 
 private:
     TelephoneInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual bool shouldRespectSpeechAttribute() OVERRIDE;
     virtual bool isTelephoneField() const OVERRIDE;

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -58,6 +58,7 @@
 #endif
 
 protected:
+    virtual void attach() OVERRIDE;
     virtual bool needsContainer() const;
     virtual bool shouldHaveSpinButton() const;
     virtual void createShadowSubtree() OVERRIDE;
@@ -91,7 +92,6 @@
     virtual HTMLElement* placeholderElement() const OVERRIDE;
     virtual void updatePlaceholderText() OVERRIDE;
     virtual bool appendFormData(FormDataList&, bool multipart) const OVERRIDE;
-    virtual void attach() OVERRIDE;
     virtual void subtreeHasChanged() OVERRIDE;
 
     // SpinButtonElement::SpinButtonOwner functions.

Modified: trunk/Source/WebCore/html/TextInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/TextInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/TextInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -31,16 +31,29 @@
 #include "config.h"
 #include "TextInputType.h"
 
+#include "HTMLInputElement.h"
 #include "InputTypeNames.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
+using namespace HTMLNames;
+
 PassOwnPtr<InputType> TextInputType::create(HTMLInputElement* element)
 {
     return adoptPtr(new TextInputType(element));
 }
 
+void TextInputType::attach()
+{
+    TextFieldInputType::attach();
+    const AtomicString& type = element()->fastGetAttribute(typeAttr);
+    if (equalIgnoringCase(type, InputTypeNames::datetime()))
+        observeFeatureIfVisible(FeatureObserver::InputTypeDateTimeFallback);
+    else if (equalIgnoringCase(type, InputTypeNames::week()))
+        observeFeatureIfVisible(FeatureObserver::InputTypeWeekFallback);
+}
+
 const AtomicString& TextInputType::formControlType() const
 {
     return InputTypeNames::text();

Modified: trunk/Source/WebCore/html/TextInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/TextInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/TextInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -41,6 +41,7 @@
 
 private:
     TextInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual bool shouldRespectSpeechAttribute() OVERRIDE;
 };

Modified: trunk/Source/WebCore/html/TimeInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/TimeInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/TimeInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -32,7 +32,6 @@
 #include "TimeInputType.h"
 
 #include "DateComponents.h"
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -64,10 +63,14 @@
 
 PassOwnPtr<InputType> TimeInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeTime);
     return adoptPtr(new TimeInputType(element));
 }
 
+void TimeInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeTime);
+}
+
 const AtomicString& TimeInputType::formControlType() const
 {
     return InputTypeNames::time();

Modified: trunk/Source/WebCore/html/TimeInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/TimeInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/TimeInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -49,6 +49,7 @@
 
 private:
     TimeInputType(HTMLInputElement*);
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual Decimal defaultValueForStepUp() const OVERRIDE;

Modified: trunk/Source/WebCore/html/URLInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/URLInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/URLInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -31,7 +31,6 @@
 #include "config.h"
 #include "URLInputType.h"
 
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "InputTypeNames.h"
 #include "LocalizedStrings.h"
@@ -42,10 +41,15 @@
 
 PassOwnPtr<InputType> URLInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeURL);
     return adoptPtr(new URLInputType(element));
 }
 
+void URLInputType::attach()
+{
+    TextFieldInputType::attach();
+    observeFeatureIfVisible(FeatureObserver::InputTypeURL);
+}
+
 const AtomicString& URLInputType::formControlType() const
 {
     return InputTypeNames::url();

Modified: trunk/Source/WebCore/html/URLInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/URLInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/URLInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -41,6 +41,7 @@
 
 private:
     URLInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual bool typeMismatchFor(const String&) const OVERRIDE;
     virtual bool typeMismatch() const OVERRIDE;

Modified: trunk/Source/WebCore/html/WeekInputType.cpp (141085 => 141086)


--- trunk/Source/WebCore/html/WeekInputType.cpp	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/WeekInputType.cpp	2013-01-29 10:01:24 UTC (rev 141086)
@@ -32,7 +32,6 @@
 #include "WeekInputType.h"
 
 #include "DateComponents.h"
-#include "FeatureObserver.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -56,10 +55,14 @@
 
 PassOwnPtr<InputType> WeekInputType::create(HTMLInputElement* element)
 {
-    FeatureObserver::observe(element->document(), FeatureObserver::InputTypeWeek);
     return adoptPtr(new WeekInputType(element));
 }
 
+void WeekInputType::attach()
+{
+    observeFeatureIfVisible(FeatureObserver::InputTypeWeek);
+}
+
 const AtomicString& WeekInputType::formControlType() const
 {
     return InputTypeNames::week();

Modified: trunk/Source/WebCore/html/WeekInputType.h (141085 => 141086)


--- trunk/Source/WebCore/html/WeekInputType.h	2013-01-29 09:41:31 UTC (rev 141085)
+++ trunk/Source/WebCore/html/WeekInputType.h	2013-01-29 10:01:24 UTC (rev 141086)
@@ -49,6 +49,7 @@
 
 private:
     WeekInputType(HTMLInputElement* element) : BaseWeekInputType(element) { }
+    virtual void attach() OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual StepRange createStepRange(AnyStepHandling) const OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to