Title: [110055] trunk/Source/WebCore
Revision
110055
Author
[email protected]
Date
2012-03-07 08:29:37 -0800 (Wed, 07 Mar 2012)

Log Message

[Forms] Introduce LabelableElement to share "labels" attribute implementation
https://bugs.webkit.org/show_bug.cgi?id=80392

Patch by Yoshifumi Inoue <[email protected]> on 2012-03-07
Reviewed by Kent Tamura.

This patch introduces new class LabelableElement as base class of
HTMLFormControlElement for sharing implementation of "labels"
attribute among form-associate elements, "meter" element, and
"progress" element.

This patch allows us to change base class of HTMLMeterElement and
HTMLProgressElement dervied from HTMLFormControlElement to
HTMLElement for remove them from HTMLFormElement::m_associatedFormElements
where we don't need to put "meter" and "progress" elements(bug 80381.)

This patch also changes implementation of isLabelable using virtual
method rather than sequence of hasTagName for execution speed and
better readability.

No new tests are required. No behavior changes.

* CMakeLists.txt: Add LabelableElement.cpp and .h
* GNUmakefile.list.am:  Add LabelableElement.cpp and .h
* Target.pri: Add LabelableElement.cpp and .h
* WebCore.gypi: Add LabelableElement.cpp and .h
* WebCore.vcproj/WebCore.vcproj: Add LabelableElement.cpp and .h
* WebCore.xcodeproj/project.pbxproj: Add LabelableElement.cpp and .h
* html/HTMLButtonElement.h: Implement isLabelable.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::HTMLFormControlElement): Change direct base class.
* html/HTMLFormControlElement.h:
(HTMLFormControlElement): Change direct base class.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::isLabelable): Removed to use virtual method instead of hasTagName.
(WebCore):
* html/HTMLInputElement.h: Declaration of isLabelable.
* html/HTMLKeygenElement.h: Implement isLabelable.
* html/HTMLMeterElement.h: Implement isLabelable.
* html/HTMLProgressElement.h: Implement isLabelable.
* html/HTMLSelectElement.h: Implement isLabelable.
* html/HTMLTextAreaElement.h: Implement isLabelable.
* html/LabelableElement.cpp: Added.
(WebCore):
(WebCore::LabelableElement::LabelableElement):
(WebCore::LabelableElement::~LabelableElement):
(WebCore::LabelableElement::labels): Moved from HTMLFormControlElement.
* html/LabelableElement.h: Added.
(WebCore):
(LabelableElement):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (110054 => 110055)


--- trunk/Source/WebCore/CMakeLists.txt	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-03-07 16:29:37 UTC (rev 110055)
@@ -829,6 +829,7 @@
     html/ImageDocument.cpp
     html/ImageInputType.cpp
     html/InputType.cpp
+    html/LabelableElement.cpp
     html/LabelsNodeList.cpp
     html/LinkRelAttribute.cpp
     html/MediaController.cpp

Modified: trunk/Source/WebCore/ChangeLog (110054 => 110055)


--- trunk/Source/WebCore/ChangeLog	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/ChangeLog	2012-03-07 16:29:37 UTC (rev 110055)
@@ -1,3 +1,55 @@
+2012-03-07  Yoshifumi Inoue  <[email protected]>
+
+        [Forms] Introduce LabelableElement to share "labels" attribute implementation
+        https://bugs.webkit.org/show_bug.cgi?id=80392
+
+        Reviewed by Kent Tamura.
+
+        This patch introduces new class LabelableElement as base class of
+        HTMLFormControlElement for sharing implementation of "labels" 
+        attribute among form-associate elements, "meter" element, and 
+        "progress" element.
+
+        This patch allows us to change base class of HTMLMeterElement and
+        HTMLProgressElement dervied from HTMLFormControlElement to 
+        HTMLElement for remove them from HTMLFormElement::m_associatedFormElements
+        where we don't need to put "meter" and "progress" elements(bug 80381.)
+
+        This patch also changes implementation of isLabelable using virtual
+        method rather than sequence of hasTagName for execution speed and
+        better readability.
+
+        No new tests are required. No behavior changes.
+
+        * CMakeLists.txt: Add LabelableElement.cpp and .h
+        * GNUmakefile.list.am:  Add LabelableElement.cpp and .h
+        * Target.pri: Add LabelableElement.cpp and .h
+        * WebCore.gypi: Add LabelableElement.cpp and .h
+        * WebCore.vcproj/WebCore.vcproj: Add LabelableElement.cpp and .h
+        * WebCore.xcodeproj/project.pbxproj: Add LabelableElement.cpp and .h
+        * html/HTMLButtonElement.h: Implement isLabelable.
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::HTMLFormControlElement): Change direct base class.
+        * html/HTMLFormControlElement.h:
+        (HTMLFormControlElement): Change direct base class.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::isLabelable): Removed to use virtual method instead of hasTagName.
+        (WebCore):
+        * html/HTMLInputElement.h: Declaration of isLabelable.
+        * html/HTMLKeygenElement.h: Implement isLabelable.
+        * html/HTMLMeterElement.h: Implement isLabelable.
+        * html/HTMLProgressElement.h: Implement isLabelable.
+        * html/HTMLSelectElement.h: Implement isLabelable.
+        * html/HTMLTextAreaElement.h: Implement isLabelable.
+        * html/LabelableElement.cpp: Added.
+        (WebCore):
+        (WebCore::LabelableElement::LabelableElement):
+        (WebCore::LabelableElement::~LabelableElement):
+        (WebCore::LabelableElement::labels): Moved from HTMLFormControlElement.
+        * html/LabelableElement.h: Added.
+        (WebCore):
+        (LabelableElement):
+
 2012-03-07  Arun Patole  <[email protected]>
 
         HTMLTrackElement.idl doesn't have default attribute.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (110054 => 110055)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-03-07 16:29:37 UTC (rev 110055)
@@ -2377,6 +2377,8 @@
 	Source/WebCore/html/ImageInputType.h \
 	Source/WebCore/html/InputType.cpp \
 	Source/WebCore/html/InputType.h \
+	Source/WebCore/html/LabelableElement.cpp \
+	Source/WebCore/html/LabelableElement.h \
 	Source/WebCore/html/LabelsNodeList.cpp \
 	Source/WebCore/html/LabelsNodeList.h \
 	Source/WebCore/html/LinkRelAttribute.cpp \

Modified: trunk/Source/WebCore/Target.pri (110054 => 110055)


--- trunk/Source/WebCore/Target.pri	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/Target.pri	2012-03-07 16:29:37 UTC (rev 110055)
@@ -811,6 +811,7 @@
     html/ImageDocument.cpp \
     html/ImageInputType.cpp \
     html/InputType.cpp \
+    html/LabelableElement.cpp \
     html/LabelsNodeList.cpp \
     html/LinkRelAttribute.cpp \
     html/MediaDocument.cpp \
@@ -1925,6 +1926,7 @@
     html/HTMLViewSourceDocument.h \
     html/ImageData.h \
     html/ImageDocument.h \
+    html/LabelableElement.h \
     html/LabelsNodeList.h \
     html/LinkRelAttribute.h \
     html/MediaController.h \

Modified: trunk/Source/WebCore/WebCore.gypi (110054 => 110055)


--- trunk/Source/WebCore/WebCore.gypi	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/WebCore.gypi	2012-03-07 16:29:37 UTC (rev 110055)
@@ -656,6 +656,7 @@
             'html/HTMLTextAreaElement.h',
             'html/HTMLTextFormControlElement.h',
             'html/InputType.h',
+            'html/LabelableElement.h',
             'html/VoidCallback.h',
             'html/parser/HTMLParserIdioms.h',
         ],
@@ -5429,6 +5430,7 @@
             'html/ImageInputType.cpp',
             'html/ImageInputType.h',
             'html/InputType.cpp',
+            'html/LabelableElement.cpp',
             'html/LabelsNodeList.cpp',
             'html/LabelsNodeList.h',
             'html/LinkRelAttribute.cpp',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (110054 => 110055)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-03-07 16:29:37 UTC (rev 110055)
@@ -61414,6 +61414,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\html\LabelableElement.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\html\LabelableElement.h"
+				>
+			</File>
+			<File
 				RelativePath="..\html\LabelsNodeList.cpp"
 				>
 			</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (110054 => 110055)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-03-07 16:29:37 UTC (rev 110055)
@@ -1168,6 +1168,8 @@
 		44A28AAC12DFB8AC00AE923B /* MathMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A28AAB12DFB8AC00AE923B /* MathMLElementFactory.h */; };
 		44A28AAF12DFB8BF00AE923B /* MathMLNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A28AAE12DFB8BF00AE923B /* MathMLNames.h */; };
 		45099C411370A7800058D513 /* IconURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45099C401370A7800058D513 /* IconURL.cpp */; };
+		450CEBF015073BBE002BB149 /* LabelableElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 450CEBEE15073BBE002BB149 /* LabelableElement.cpp */; };
+		450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 450CEBEF15073BBE002BB149 /* LabelableElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		45BAC2B01360BBAB005DA258 /* IconURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 45BAC2AF1360BBAB005DA258 /* IconURL.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4614A1FE0B23A8D600446E1C /* copyCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 4614A1FD0B23A8D600446E1C /* copyCursor.png */; };
 		46700ED0127B96CB00F5D5D6 /* FileWriterSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46700ECE127B96CB00F5D5D6 /* FileWriterSync.cpp */; };
@@ -8054,6 +8056,8 @@
 		44D8DA98139545BE00337B75 /* SVGMPathElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGMPathElement.idl; sourceTree = "<group>"; };
 		44D8DA9A139545CD00337B75 /* SVGAnimateMotionElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGAnimateMotionElement.idl; sourceTree = "<group>"; };
 		45099C401370A7800058D513 /* IconURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IconURL.cpp; sourceTree = "<group>"; };
+		450CEBEE15073BBE002BB149 /* LabelableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LabelableElement.cpp; sourceTree = "<group>"; };
+		450CEBEF15073BBE002BB149 /* LabelableElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelableElement.h; sourceTree = "<group>"; };
 		45BAC2AF1360BBAB005DA258 /* IconURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconURL.h; sourceTree = "<group>"; };
 		4614A1FD0B23A8D600446E1C /* copyCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = copyCursor.png; sourceTree = "<group>"; };
 		46700ECE127B96CB00F5D5D6 /* FileWriterSync.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileWriterSync.cpp; path = fileapi/FileWriterSync.cpp; sourceTree = "<group>"; };
@@ -16959,6 +16963,8 @@
 				F55B3D8E1251F12D003EF269 /* ImageInputType.h */,
 				37E3524A12450C5200BAF5D9 /* InputType.cpp */,
 				37E3524C12450C6600BAF5D9 /* InputType.h */,
+				450CEBEE15073BBE002BB149 /* LabelableElement.cpp */,
+				450CEBEF15073BBE002BB149 /* LabelableElement.h */,
 				A456FA2411AD4A830020B420 /* LabelsNodeList.cpp */,
 				A456FA2511AD4A830020B420 /* LabelsNodeList.h */,
 				985BB96B13A94058007A0B69 /* LinkRelAttribute.cpp */,
@@ -24539,6 +24545,7 @@
 				E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
 				977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
 				FD537353137B651800008DCE /* ZeroPole.h in Headers */,
+				450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -27512,6 +27519,7 @@
 				E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
 				977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
 				FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
+				450CEBF015073BBE002BB149 /* LabelableElement.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/html/HTMLButtonElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLButtonElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLButtonElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -49,6 +49,7 @@
     virtual bool appendFormData(FormDataList&, bool);
 
     virtual bool isEnumeratable() const { return true; } 
+    virtual bool isLabelable() const OVERRIDE { return true; }
 
     virtual bool isSuccessfulSubmitButton() const;
     virtual bool isActivatedSubmit() const;

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2012-03-07 16:29:37 UTC (rev 110055)
@@ -26,16 +26,12 @@
 #include "HTMLFormControlElement.h"
 
 #include "Attribute.h"
-#include "Document.h"
-#include "ElementRareData.h"
 #include "Event.h"
 #include "EventHandler.h"
 #include "EventNames.h"
 #include "Frame.h"
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
-#include "HTMLNames.h"
-#include "LabelsNodeList.h"
 #include "RenderBox.h"
 #include "RenderTheme.h"
 #include "ScriptEventListener.h"
@@ -49,7 +45,7 @@
 using namespace std;
 
 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
-    : HTMLElement(tagName, document)
+    : LabelableElement(tagName, document)
     , m_disabled(false)
     , m_readOnly(false)
     , m_required(false)
@@ -467,33 +463,4 @@
     return isSuccessfulSubmitButton() && form() && form()->defaultButton() == this;
 }
 
-bool HTMLFormControlElement::isLabelable() const
-{
-    // FIXME: Add meterTag and outputTag to the list once we support them.
-    return hasTagName(buttonTag) || hasTagName(inputTag) || hasTagName(keygenTag)
-#if ENABLE(METER_TAG)
-        || hasTagName(meterTag)
-#endif
-#if ENABLE(PROGRESS_TAG)
-        || hasTagName(progressTag)
-#endif
-        || hasTagName(selectTag) || hasTagName(textareaTag);
-}
-
-PassRefPtr<NodeList> HTMLFormControlElement::labels()
-{
-    if (!isLabelable())
-        return 0;
-    if (!document())
-        return 0;
-
-    NodeListsNodeData* nodeLists = Node::ensureRareData()->ensureNodeLists(this);
-    if (nodeLists->m_labelsNodeListCache)
-        return nodeLists->m_labelsNodeListCache;
-
-    RefPtr<LabelsNodeList> list = LabelsNodeList::create(this);
-    nodeLists->m_labelsNodeListCache = list.get();
-    return list.release();
-}
-
 } // namespace Webcore

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLFormControlElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -25,7 +25,7 @@
 #define HTMLFormControlElement_h
 
 #include "FormAssociatedElement.h"
-#include "HTMLElement.h"
+#include "LabelableElement.h"
 
 namespace WebCore {
 
@@ -37,7 +37,7 @@
 // HTMLFormControlElement is the default implementation of FormAssociatedElement,
 // and form-associated element implementations should use HTMLFormControlElement
 // unless there is a special reason.
-class HTMLFormControlElement : public HTMLElement, public FormAssociatedElement {
+class HTMLFormControlElement : public LabelableElement, public FormAssociatedElement {
 public:
     virtual ~HTMLFormControlElement();
 
@@ -100,9 +100,6 @@
     void setNeedsValidityCheck();
     void setCustomValidity(const String&);
 
-    bool isLabelable() const;
-    PassRefPtr<NodeList> labels();
-
     bool readOnly() const { return m_readOnly; }
 
     bool hasAutofocused() { return m_hasAutofocused; }

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-03-07 16:29:37 UTC (rev 110055)
@@ -1760,6 +1760,12 @@
     return m_inputType->isEnumeratable();
 }
 
+bool HTMLInputElement::isLabelable() const
+{
+    // FIXME: We should return false for type="hidden".
+    return true;
+}
+
 bool HTMLInputElement::shouldAppearChecked() const
 {
     return checked() && m_inputType->isCheckable();

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -256,6 +256,7 @@
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;
     virtual bool isEnumeratable() const;
+    virtual bool isLabelable() const OVERRIDE;
     virtual void updateFocusAppearance(bool restorePreviousSelection);
     virtual void aboutToUnload();
     virtual bool shouldUseInputMethod();

Modified: trunk/Source/WebCore/html/HTMLKeygenElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLKeygenElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLKeygenElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -48,6 +48,7 @@
     virtual bool isOptionalFormControl() const { return false; }
 
     virtual bool isEnumeratable() const { return true; }
+    virtual bool isLabelable() const OVERRIDE { return true; }
 
     virtual void reset();
 

Modified: trunk/Source/WebCore/html/HTMLMeterElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLMeterElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLMeterElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -65,6 +65,8 @@
     HTMLMeterElement(const QualifiedName&, Document*, HTMLFormElement*);
     virtual ~HTMLMeterElement();
 
+    virtual bool isLabelable() const OVERRIDE { return true; }
+
     virtual bool supportsFocus() const;
 
     virtual bool recalcWillValidate() const { return false; }

Modified: trunk/Source/WebCore/html/HTMLProgressElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLProgressElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLProgressElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -51,6 +51,8 @@
     HTMLProgressElement(const QualifiedName&, Document*, HTMLFormElement*);
     virtual ~HTMLProgressElement();
 
+    virtual bool isLabelable() const OVERRIDE { return true; }
+
     virtual bool supportsFocus() const;
 
     virtual bool recalcWillValidate() const { return false; }

Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLSelectElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -117,6 +117,7 @@
     virtual bool canStartSelection() const { return false; }
 
     virtual bool isEnumeratable() const { return true; }
+    virtual bool isLabelable() const OVERRIDE { return true; }
 
     virtual bool saveFormControlState(String& value) const;
     virtual void restoreFormControlState(const String&);

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (110054 => 110055)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2012-03-07 15:46:58 UTC (rev 110054)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -84,6 +84,7 @@
     virtual void subtreeHasChanged();
 
     virtual bool isEnumeratable() const { return true; }
+    virtual bool isLabelable() const OVERRIDE { return true; }
 
     virtual const AtomicString& formControlType() const;
 

Added: trunk/Source/WebCore/html/LabelableElement.cpp (0 => 110055)


--- trunk/Source/WebCore/html/LabelableElement.cpp	                        (rev 0)
+++ trunk/Source/WebCore/html/LabelableElement.cpp	2012-03-07 16:29:37 UTC (rev 110055)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 1999 Lars Knoll ([email protected])
+ *           (C) 1999 Antti Koivisto ([email protected])
+ *           (C) 2001 Dirk Mueller ([email protected])
+ * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ *           (C) 2006 Alexey Proskuryakov ([email protected])
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "LabelableElement.h"
+
+#include "ElementRareData.h"
+#include "LabelsNodeList.h"
+#include "RenderStyle.h"
+
+namespace WebCore {
+
+LabelableElement::LabelableElement(const QualifiedName& tagName, Document* document)
+    : HTMLElement(tagName, document)
+{
+}
+
+LabelableElement::~LabelableElement()
+{
+}
+
+PassRefPtr<NodeList> LabelableElement::labels()
+{
+    if (!isLabelable())
+        return 0;
+    if (!document())
+        return 0;
+
+    NodeListsNodeData* nodeLists = Node::ensureRareData()->ensureNodeLists(this);
+    if (nodeLists->m_labelsNodeListCache)
+        return nodeLists->m_labelsNodeListCache;
+
+    RefPtr<LabelsNodeList> list = LabelsNodeList::create(this);
+    nodeLists->m_labelsNodeListCache = list.get();
+    return list.release();
+}
+
+} // namespace Webcore

Added: trunk/Source/WebCore/html/LabelableElement.h (0 => 110055)


--- trunk/Source/WebCore/html/LabelableElement.h	                        (rev 0)
+++ trunk/Source/WebCore/html/LabelableElement.h	2012-03-07 16:29:37 UTC (rev 110055)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LabelableElement_h
+#define LabelableElement_h
+
+#include "HTMLElement.h"
+
+namespace WebCore {
+
+// LabelableElement represents "labelable element" defined in the HTML
+// specification, and provides the implementation of the "labels" attribute.
+class LabelableElement : public HTMLElement {
+public:
+    virtual ~LabelableElement();
+    virtual bool isLabelable() const { return false; }
+    PassRefPtr<NodeList> labels();
+
+protected:
+    LabelableElement(const QualifiedName& tagName, Document*);
+};
+
+} // namespace WebCore
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to