Add RenderElement
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 17:52:38 +0000 (17:52 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 17:52:38 +0000 (17:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121608

Reviewed by Dave Hyatt.

Add a common base class for all Element renderers. The class hierarchy will now look like this

RenderObject
    RenderText
    RenderElement
        RenderLayerModelObject
            ...
        RenderSVGModelObject
            ...
        RenderSVGGradientStop

This will allow tighter typing in both render and DOM trees.

The patch also moves renderer factory function to RenderElement::createFor().

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

28 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Element.cpp
Source/WebCore/html/HTMLAppletElement.cpp
Source/WebCore/html/HTMLBRElement.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLFrameSetElement.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLMeterElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLProgressElement.cpp
Source/WebCore/html/InputType.cpp
Source/WebCore/rendering/RenderElement.cpp [new file with mode: 0644]
Source/WebCore/rendering/RenderElement.h [new file with mode: 0644]
Source/WebCore/rendering/RenderLayerModelObject.cpp
Source/WebCore/rendering/RenderLayerModelObject.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderingAllInOne.cpp
Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp
Source/WebCore/rendering/svg/RenderSVGGradientStop.h
Source/WebCore/rendering/svg/RenderSVGModelObject.cpp
Source/WebCore/rendering/svg/RenderSVGModelObject.h
Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

index 87989a0..1c7c589 100644 (file)
@@ -2131,6 +2131,7 @@ set(WebCore_SOURCES
     rendering/RenderCounter.cpp
     rendering/RenderDeprecatedFlexibleBox.cpp
     rendering/RenderDetailsMarker.cpp
+    rendering/RenderElement.cpp
     rendering/RenderEmbeddedObject.cpp
     rendering/RenderFieldset.cpp
     rendering/RenderFileUploadControl.cpp
index f692ba2..fb8d937 100644 (file)
@@ -1,3 +1,25 @@
+2013-09-19  Antti Koivisto  <antti@apple.com>
+
+        Add RenderElement
+        https://bugs.webkit.org/show_bug.cgi?id=121608
+
+        Reviewed by Dave Hyatt.
+
+        Add a common base class for all Element renderers. The class hierarchy will now look like this
+        
+        RenderObject
+            RenderText
+            RenderElement
+                RenderLayerModelObject
+                    ...
+                RenderSVGModelObject
+                    ...
+                RenderSVGGradientStop
+                
+        This will allow tighter typing in both render and DOM trees.
+        
+        The patch also moves renderer factory function to RenderElement::createFor().
+
 2013-09-19  Alexey Proskuryakov  <ap@apple.com>
 
         REGRESSION (r149928): CanvasStyle::operator= leaks everything
index 8fe8780..beac318 100644 (file)
@@ -4426,6 +4426,8 @@ webcore_sources += \
        Source/WebCore/rendering/RenderDeprecatedFlexibleBox.h \
        Source/WebCore/rendering/RenderDetailsMarker.cpp \
        Source/WebCore/rendering/RenderDetailsMarker.h \
+       Source/WebCore/rendering/RenderElement.cpp \
+       Source/WebCore/rendering/RenderElement.h \
        Source/WebCore/rendering/RenderEmbeddedObject.cpp \
        Source/WebCore/rendering/RenderEmbeddedObject.h \
        Source/WebCore/rendering/RenderFieldset.cpp \
index 9a833fe..646c44d 100644 (file)
@@ -1160,6 +1160,7 @@ SOURCES += \
     rendering/RenderCounter.cpp \
     rendering/RenderDeprecatedFlexibleBox.cpp \
     rendering/RenderDetailsMarker.cpp \
+    rendering/RenderElement.cpp \
     rendering/RenderEmbeddedObject.cpp \
     rendering/RenderFieldset.cpp \
     rendering/RenderFileUploadControl.cpp \
@@ -2429,6 +2430,7 @@ HEADERS += \
     rendering/RenderCounter.h \
     rendering/RenderDeprecatedFlexibleBox.h \
     rendering/RenderDetailsMarker.h \
+    rendering/RenderElement.h \
     rendering/RenderEmbeddedObject.h \
     rendering/RenderFieldset.h \
     rendering/RenderFileUploadControl.h \
index 719a5c2..30fe8fb 100644 (file)
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\rendering\RenderElement.cpp">
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+        <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\rendering\RenderEmbeddedObject.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
     <ClInclude Include="..\rendering\RenderCounter.h" />
     <ClInclude Include="..\rendering\RenderDeprecatedFlexibleBox.h" />
     <ClInclude Include="..\rendering\RenderDetailsMarker.h" />
+    <ClInclude Include="..\rendering\RenderElement.h" />
     <ClInclude Include="..\rendering\RenderEmbeddedObject.h" />
     <ClInclude Include="..\rendering\RenderFieldset.h" />
     <ClInclude Include="..\rendering\RenderFileUploadControl.h" />
index 50bdf6d..4bb8fa1 100644 (file)
                436708C512D9CA4B00044234 /* RenderSVGGradientStop.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088612D9CA4A00044234 /* RenderSVGGradientStop.h */; };
                436708C712D9CA4B00044234 /* RenderSVGHiddenContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088812D9CA4A00044234 /* RenderSVGHiddenContainer.h */; };
                436708C912D9CA4B00044234 /* RenderSVGImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088A12D9CA4A00044234 /* RenderSVGImage.h */; };
-               436708CB12D9CA4B00044234 /* RenderSVGModelObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088C12D9CA4A00044234 /* RenderSVGModelObject.h */; };
+               436708CB12D9CA4B00044234 /* RenderSVGModelObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088C12D9CA4A00044234 /* RenderSVGModelObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                436708CD12D9CA4B00044234 /* RenderSVGResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088E12D9CA4A00044234 /* RenderSVGResource.h */; };
                436708CF12D9CA4B00044234 /* RenderSVGResourceClipper.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367089012D9CA4A00044234 /* RenderSVGResourceClipper.h */; };
                436708D112D9CA4B00044234 /* RenderSVGResourceContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367089212D9CA4A00044234 /* RenderSVGResourceContainer.h */; };
                E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */ = {isa = PBXBuildFile; fileRef = E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E43105B816750F0C00DB2FB8 /* NodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */; };
                E43105BB16750F1600DB2FB8 /* NodeTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E43105BA16750F1600DB2FB8 /* NodeTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E43A023B17EB370A004CDD25 /* RenderElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E43A023A17EB370A004CDD25 /* RenderElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E43A023D17EB3713004CDD25 /* RenderElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43A023C17EB3713004CDD25 /* RenderElement.cpp */; };
                E44613A10CD6331000FADA75 /* HTMLAudioElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */; };
                E44613A20CD6331000FADA75 /* HTMLAudioElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613900CD6331000FADA75 /* HTMLAudioElement.h */; };
                E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44613920CD6331000FADA75 /* HTMLMediaElement.cpp */; };
                E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadPriority.h; sourceTree = "<group>"; };
                E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodeTraversal.cpp; sourceTree = "<group>"; };
                E43105BA16750F1600DB2FB8 /* NodeTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeTraversal.h; sourceTree = "<group>"; };
+               E43A023A17EB370A004CDD25 /* RenderElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderElement.h; sourceTree = "<group>"; };
+               E43A023C17EB3713004CDD25 /* RenderElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderElement.cpp; sourceTree = "<group>"; };
                E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLAudioElement.cpp; sourceTree = "<group>"; };
                E44613900CD6331000FADA75 /* HTMLAudioElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLAudioElement.h; sourceTree = "<group>"; };
                E44613910CD6331000FADA75 /* HTMLAudioElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLAudioElement.idl; sourceTree = "<group>"; };
                                BCEA482F097D93020094C9E4 /* RenderDeprecatedFlexibleBox.h */,
                                D302754512A5FE84004BD828 /* RenderDetailsMarker.cpp */,
                                D302754612A5FE84004BD828 /* RenderDetailsMarker.h */,
+                               E43A023A17EB370A004CDD25 /* RenderElement.h */,
+                               E43A023C17EB3713004CDD25 /* RenderElement.cpp */,
                                0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */,
                                0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */,
                                A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */,
                                088A0E0B126EF1DB00978F7A /* SVGPropertyTearOff.h in Headers */,
                                088A0E0C126EF1DB00978F7A /* SVGPropertyTraits.h in Headers */,
                                B2227A9A0D00BF220071B782 /* SVGRadialGradientElement.h in Headers */,
+                               E43A023B17EB370A004CDD25 /* RenderElement.h in Headers */,
                                08EDE19F12A50B8E00B95797 /* SVGRect.h in Headers */,
                                B2227A9E0D00BF220071B782 /* SVGRectElement.h in Headers */,
                                197B180C1506353200E4ADA8 /* SVGRenderingContext.h in Headers */,
                                BC53DA62114314BD000D817E /* DOMObjectHashTableMap.cpp in Sources */,
                                85C7F5D10AAFB8D9004014DD /* DOMOverflowEvent.mm in Sources */,
                                E1284BD51044A01E00EAEB52 /* DOMPageTransitionEvent.mm in Sources */,
+                               E43A023D17EB3713004CDD25 /* RenderElement.cpp in Sources */,
                                1ACE53E70A8D18E70022947D /* DOMParser.cpp in Sources */,
                                7A54881814E432A1006AE05A /* DOMPatchSupport.cpp in Sources */,
                                A9C6E4EB0D745E2B006442E9 /* DOMPlugin.cpp in Sources */,
index 3bda2d3..8d5f752 100644 (file)
@@ -1264,7 +1264,7 @@ bool Element::rendererIsNeeded(const RenderStyle& style)
 
 RenderObject* Element::createRenderer(RenderArena&, RenderStyle& style)
 {
-    return RenderObject::createObject(*this, style);
+    return RenderElement::createFor(*this, style);
 }
 
 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertionPoint)
index 4048275..03dbfa0 100644 (file)
@@ -78,7 +78,7 @@ bool HTMLAppletElement::rendererIsNeeded(const RenderStyle& style)
 RenderObject* HTMLAppletElement::createRenderer(RenderArena&, RenderStyle& style)
 {
     if (!canEmbedJava())
-        return RenderObject::createObject(*this, style);
+        return RenderElement::createFor(*this, style);
 
     return RenderEmbeddedObject::createForApplet(*this);
 }
index 326b322..8ee12d1 100644 (file)
@@ -74,7 +74,7 @@ void HTMLBRElement::collectStyleForPresentationAttribute(const QualifiedName& na
 RenderObject* HTMLBRElement::createRenderer(RenderArena& arena, RenderStyle& style)
 {
     if (style.hasContent())
-        return RenderObject::createObject(*this, style);
+        return RenderElement::createFor(*this, style);
 
     return new (arena) RenderLineBreak(*this);
 }
index 48e5aaf..57ff8b7 100644 (file)
@@ -792,7 +792,7 @@ RenderObject* HTMLElement::createRenderer(RenderArena& arena, RenderStyle& style
 {
     if (hasLocalName(wbrTag))
         return new (arena) RenderLineBreak(*this);
-    return RenderObject::createObject(*this, style);
+    return RenderElement::createFor(*this, style);
 }
 
 HTMLFormElement* HTMLElement::virtualForm() const
index a4e4f5b..d347e0d 100644 (file)
@@ -159,7 +159,7 @@ bool HTMLFrameSetElement::rendererIsNeeded(const RenderStyle& style)
 RenderObject* HTMLFrameSetElement::createRenderer(RenderArena& arena, RenderStyle& style)
 {
     if (style.hasContent())
-        return RenderObject::createObject(*this, style);
+        return RenderElement::createFor(*this, style);
     
     return new (arena) RenderFrameSet(*this);
 }
index e7192c5..3ccb5bb 100644 (file)
@@ -166,7 +166,7 @@ String HTMLImageElement::altText() const
 RenderObject* HTMLImageElement::createRenderer(RenderArena& arena, RenderStyle& style)
 {
     if (style.hasContent())
-        return RenderObject::createObject(*this, style);
+        return RenderElement::createFor(*this, style);
 
     RenderImage* image = new (arena) RenderImage(this);
     image->setImageResource(RenderImageResource::create());
index cc74b20..1cb9851 100644 (file)
@@ -59,7 +59,7 @@ PassRefPtr<HTMLMeterElement> HTMLMeterElement::create(const QualifiedName& tagNa
 RenderObject* HTMLMeterElement::createRenderer(RenderArena& arena, RenderStyle& style)
 {
     if (hasAuthorShadowRoot() || !document().page()->theme()->supportsMeter(style.appearance()))
-        return RenderObject::createObject(*this, style);
+        return RenderElement::createFor(*this, style);
 
     return new (arena) RenderMeter(this);
 }
index a554bf0..477d20f 100644 (file)
@@ -213,7 +213,7 @@ RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena& arena, RenderS
     // class and all superclasses because createObject won't necessarily
     // return a RenderEmbeddedObject or RenderWidget.
     if (useFallbackContent())
-        return RenderObject::createObject(*this, style);
+        return RenderElement::createFor(*this, style);
 
     if (isImageType()) {
         RenderImage* image = new (arena) RenderImage(this);
index af642b2..77fd309 100644 (file)
@@ -61,7 +61,7 @@ PassRefPtr<HTMLProgressElement> HTMLProgressElement::create(const QualifiedName&
 RenderObject* HTMLProgressElement::createRenderer(RenderArena& arena, RenderStyle& style)
 {
     if (!style.hasAppearance() || hasAuthorShadowRoot())
-        return RenderObject::createObject(*this, style);
+        return RenderElement::createFor(*this, style);
 
     return new (arena) RenderProgress(this);
 }
index 386868a..720bff5 100644 (file)
@@ -61,7 +61,7 @@
 #include "RadioInputType.h"
 #include "RangeInputType.h"
 #include "RegularExpression.h"
-#include "RenderObject.h"
+#include "RenderElement.h"
 #include "RenderTheme.h"
 #include "ResetInputType.h"
 #include "RuntimeEnabledFeatures.h"
@@ -470,7 +470,7 @@ PassRefPtr<HTMLFormElement> InputType::formForSubmission() const
 
 RenderObject* InputType::createRenderer(RenderArena&, RenderStyle& style) const
 {
-    return RenderObject::createObject(element(), style);
+    return RenderElement::createFor(element(), style);
 }
 
 void InputType::blur()
diff --git a/Source/WebCore/rendering/RenderElement.cpp b/Source/WebCore/rendering/RenderElement.cpp
new file mode 100644 (file)
index 0000000..caed0cc
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
+ *           (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2012 Google Inc. All rights reserved.
+ *
+ * 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 "RenderElement.h"
+
+#include "ContentData.h"
+#include "RenderDeprecatedFlexibleBox.h"
+#include "RenderFlexibleBox.h"
+#include "RenderGrid.h"
+#include "RenderImage.h"
+#include "RenderImageResourceStyleImage.h"
+#include "RenderListItem.h"
+#include "RenderMultiColumnBlock.h"
+#include "RenderRegion.h"
+#include "RenderRuby.h"
+#include "RenderRubyText.h"
+#include "RenderTableCaption.h"
+#include "RenderTableCell.h"
+#include "RenderTableCol.h"
+#include "RenderTableRow.h"
+
+namespace WebCore {
+
+RenderElement::RenderElement(Element* element)
+    : RenderObject(element)
+{
+}
+
+RenderElement::~RenderElement()
+{
+}
+
+RenderElement* RenderElement::createFor(Element& element, RenderStyle& style)
+{
+    Document& document = element.document();
+    RenderArena& arena = *document.renderArena();
+
+    // Minimal support for content properties replacing an entire element.
+    // Works only if we have exactly one piece of content and it's a URL.
+    // Otherwise acts as if we didn't support this feature.
+    const ContentData* contentData = style.contentData();
+    if (contentData && !contentData->next() && contentData->isImage() && !element.isPseudoElement()) {
+        RenderImage* image = new (arena) RenderImage(&element);
+        // RenderImageResourceStyleImage requires a style being present on the image but we don't want to
+        // trigger a style change now as the node is not fully attached. Moving this code to style change
+        // doesn't make sense as it should be run once at renderer creation.
+        image->setStyleInternal(&style);
+        if (const StyleImage* styleImage = static_cast<const ImageContentData*>(contentData)->image()) {
+            image->setImageResource(RenderImageResourceStyleImage::create(const_cast<StyleImage*>(styleImage)));
+            image->setIsGeneratedContent();
+        } else
+            image->setImageResource(RenderImageResource::create());
+        image->setStyleInternal(0);
+        return image;
+    }
+
+    if (element.hasTagName(HTMLNames::rubyTag)) {
+        if (style.display() == INLINE)
+            return new (arena) RenderRubyAsInline(element);
+        if (style.display() == BLOCK)
+            return new (arena) RenderRubyAsBlock(element);
+    }
+    // treat <rt> as ruby text ONLY if it still has its default treatment of block
+    if (element.hasTagName(HTMLNames::rtTag) && style.display() == BLOCK)
+        return new (arena) RenderRubyText(element);
+    if (document.cssRegionsEnabled() && style.isDisplayRegionType() && !style.regionThread().isEmpty())
+        return new (arena) RenderRegion(&element, 0);
+    switch (style.display()) {
+    case NONE:
+        return 0;
+    case INLINE:
+        return new (arena) RenderInline(&element);
+    case BLOCK:
+    case INLINE_BLOCK:
+    case RUN_IN:
+    case COMPACT:
+        if ((!style.hasAutoColumnCount() || !style.hasAutoColumnWidth()) && document.regionBasedColumnsEnabled())
+            return new (arena) RenderMultiColumnBlock(element);
+        return new (arena) RenderBlockFlow(&element);
+    case LIST_ITEM:
+        return new (arena) RenderListItem(element);
+    case TABLE:
+    case INLINE_TABLE:
+        return new (arena) RenderTable(&element);
+    case TABLE_ROW_GROUP:
+    case TABLE_HEADER_GROUP:
+    case TABLE_FOOTER_GROUP:
+        return new (arena) RenderTableSection(&element);
+    case TABLE_ROW:
+        return new (arena) RenderTableRow(&element);
+    case TABLE_COLUMN_GROUP:
+    case TABLE_COLUMN:
+        return new (arena) RenderTableCol(element);
+    case TABLE_CELL:
+        return new (arena) RenderTableCell(&element);
+    case TABLE_CAPTION:
+        return new (arena) RenderTableCaption(element);
+    case BOX:
+    case INLINE_BOX:
+        return new (arena) RenderDeprecatedFlexibleBox(element);
+    case FLEX:
+    case INLINE_FLEX:
+        return new (arena) RenderFlexibleBox(&element);
+    case GRID:
+    case INLINE_GRID:
+        return new (arena) RenderGrid(element);
+    }
+
+    return nullptr;
+}
+
+}
diff --git a/Source/WebCore/rendering/RenderElement.h b/Source/WebCore/rendering/RenderElement.h
new file mode 100644 (file)
index 0000000..45e5025
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2003, 2006, 2007, 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2012 Google Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef RenderElement_h
+#define RenderElement_h
+
+#include "RenderObject.h"
+
+namespace WebCore {
+
+class RenderElement : public RenderObject {
+public:
+    virtual ~RenderElement();
+
+    static RenderElement* createFor(Element&, RenderStyle&);
+
+    // This is null for anonymous renderers.
+    Element* element() const { return toElement(RenderObject::node()); }
+    Element* nonPseudoElement() const { return toElement(RenderObject::nonPseudoNode()); }
+    Element* generatingElement() const { return toElement(RenderObject::generatingNode()); }
+
+protected:
+    explicit RenderElement(Element*);
+
+private:
+    void node() const WTF_DELETED_FUNCTION;
+    void nonPseudoNode() const WTF_DELETED_FUNCTION;
+    void generatingNode() const WTF_DELETED_FUNCTION;
+};
+
+} // namespace WebCore
+
+#endif // RenderElement_h
index 9d135df..0d89ad8 100644 (file)
@@ -38,7 +38,7 @@ bool RenderLayerModelObject::s_hadTransform = false;
 bool RenderLayerModelObject::s_layerWasSelfPainting = false;
 
 RenderLayerModelObject::RenderLayerModelObject(Element* element)
-    : RenderObject(element)
+    : RenderElement(element)
     , m_layer(0)
 {
 }
index 9030d51..c21563e 100644 (file)
 #ifndef RenderLayerModelObject_h
 #define RenderLayerModelObject_h
 
-#include "RenderObject.h"
+#include "RenderElement.h"
 
 namespace WebCore {
 
 class RenderLayer;
 
-class RenderLayerModelObject : public RenderObject {
+class RenderLayerModelObject : public RenderElement {
 public:
     explicit RenderLayerModelObject(Element*);
     virtual ~RenderLayerModelObject();
@@ -50,11 +50,6 @@ public:
     // The query rect is given in local coordinate system.
     virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { return false; }
 
-    // This is null for anonymous renderers.
-    Element* element() const { return toElement(RenderObject::node()); }
-    Element* nonPseudoElement() const { return toElement(RenderObject::nonPseudoNode()); }
-    Element* generatingElement() const { return toElement(RenderObject::generatingNode()); }
-
 protected:
     void ensureLayer();
     virtual bool updateLayerIfNeeded();
@@ -64,10 +59,6 @@ protected:
 private:
     virtual bool isLayerModelObject() const OVERRIDE FINAL { return true; }
 
-    void node() const WTF_DELETED_FUNCTION;
-    void nonPseudoNode() const WTF_DELETED_FUNCTION;
-    void generatingNode() const WTF_DELETED_FUNCTION;
-
     RenderLayer* m_layer;
 
     // Used to store state between styleWillChange and styleDidChange
index 69a8c35..b0550a8 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2000 Dirk Mueller (mueller@kde.org)
  *           (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011, 2013 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Google Inc. All rights reserved.
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  *
@@ -29,7 +29,6 @@
 
 #include "AXObjectCache.h"
 #include "AnimationController.h"
-#include "ContentData.h"
 #include "CursorList.h"
 #include "EventHandler.h"
 #include "FloatQuad.h"
 #include "PseudoElement.h"
 #include "RenderArena.h"
 #include "RenderCounter.h"
-#include "RenderDeprecatedFlexibleBox.h"
-#include "RenderFlexibleBox.h"
+#include "RenderFlowThread.h"
 #include "RenderGeometryMap.h"
-#include "RenderGrid.h"
-#include "RenderImage.h"
-#include "RenderImageResourceStyleImage.h"
 #include "RenderInline.h"
 #include "RenderLayer.h"
 #include "RenderLayerBacking.h"
-#include "RenderListItem.h"
-#include "RenderMultiColumnBlock.h"
 #include "RenderNamedFlowThread.h"
-#include "RenderRegion.h"
-#include "RenderRuby.h"
-#include "RenderRubyText.h"
 #include "RenderScrollbarPart.h"
-#include "RenderTableCaption.h"
-#include "RenderTableCell.h"
+#include "RenderTable.h"
 #include "RenderTableCol.h"
-#include "RenderTableRow.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "Settings.h"
@@ -161,85 +149,6 @@ void RenderObject::operator delete(void* ptr, size_t sz)
     *(size_t *)ptr = sz;
 }
 
-RenderObject* RenderObject::createObject(Element& element, RenderStyle& style)
-{
-    Document& document = element.document();
-    RenderArena& arena = *document.renderArena();
-
-    // Minimal support for content properties replacing an entire element.
-    // Works only if we have exactly one piece of content and it's a URL.
-    // Otherwise acts as if we didn't support this feature.
-    const ContentData* contentData = style.contentData();
-    if (contentData && !contentData->next() && contentData->isImage() && !element.isPseudoElement()) {
-        RenderImage* image = new (arena) RenderImage(&element);
-        // RenderImageResourceStyleImage requires a style being present on the image but we don't want to
-        // trigger a style change now as the node is not fully attached. Moving this code to style change
-        // doesn't make sense as it should be run once at renderer creation.
-        image->setStyleInternal(&style);
-        if (const StyleImage* styleImage = static_cast<const ImageContentData*>(contentData)->image()) {
-            image->setImageResource(RenderImageResourceStyleImage::create(const_cast<StyleImage*>(styleImage)));
-            image->setIsGeneratedContent();
-        } else
-            image->setImageResource(RenderImageResource::create());
-        image->setStyleInternal(0);
-        return image;
-    }
-
-    if (element.hasTagName(rubyTag)) {
-        if (style.display() == INLINE)
-            return new (arena) RenderRubyAsInline(element);
-        else if (style.display() == BLOCK)
-            return new (arena) RenderRubyAsBlock(element);
-    }
-    // treat <rt> as ruby text ONLY if it still has its default treatment of block
-    if (element.hasTagName(rtTag) && style.display() == BLOCK)
-        return new (arena) RenderRubyText(element);
-    if (document.cssRegionsEnabled() && style.isDisplayRegionType() && !style.regionThread().isEmpty())
-        return new (arena) RenderRegion(&element, 0);
-    switch (style.display()) {
-    case NONE:
-        return 0;
-    case INLINE:
-        return new (arena) RenderInline(&element);
-    case BLOCK:
-    case INLINE_BLOCK:
-    case RUN_IN:
-    case COMPACT:
-        if ((!style.hasAutoColumnCount() || !style.hasAutoColumnWidth()) && document.regionBasedColumnsEnabled())
-            return new (arena) RenderMultiColumnBlock(element);
-        return new (arena) RenderBlockFlow(&element);
-    case LIST_ITEM:
-        return new (arena) RenderListItem(element);
-    case TABLE:
-    case INLINE_TABLE:
-        return new (arena) RenderTable(&element);
-    case TABLE_ROW_GROUP:
-    case TABLE_HEADER_GROUP:
-    case TABLE_FOOTER_GROUP:
-        return new (arena) RenderTableSection(&element);
-    case TABLE_ROW:
-        return new (arena) RenderTableRow(&element);
-    case TABLE_COLUMN_GROUP:
-    case TABLE_COLUMN:
-        return new (arena) RenderTableCol(element);
-    case TABLE_CELL:
-        return new (arena) RenderTableCell(&element);
-    case TABLE_CAPTION:
-        return new (arena) RenderTableCaption(element);
-    case BOX:
-    case INLINE_BOX:
-        return new (arena) RenderDeprecatedFlexibleBox(element);
-    case FLEX:
-    case INLINE_FLEX:
-        return new (arena) RenderFlexibleBox(&element);
-    case GRID:
-    case INLINE_GRID:
-        return new (arena) RenderGrid(element);
-    }
-
-    return 0;
-}
-
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, renderObjectCounter, ("RenderObject"));
 
 RenderObject::RenderObject(Node* node)
index fb7ba3c..f3c8b37 100644 (file)
@@ -326,8 +326,6 @@ public:
     void showRenderTreeAndMark(const RenderObject* markedObject1 = 0, const char* markedLabel1 = 0, const RenderObject* markedObject2 = 0, const char* markedLabel2 = 0, int depth = 0) const;
 #endif
 
-    static RenderObject* createObject(Element&, RenderStyle&);
-
     // Overloaded new operator.  Derived classes must override operator new
     // in order to allocate out of the RenderArena.
     void* operator new(size_t, RenderArena&);
index 6e93709..31d35cf 100644 (file)
@@ -53,6 +53,7 @@
 #include "RenderCounter.cpp"
 #include "RenderDeprecatedFlexibleBox.cpp"
 #include "RenderDetailsMarker.cpp"
+#include "RenderElement.cpp"
 #include "RenderEmbeddedObject.cpp"
 #include "RenderFieldset.cpp"
 #include "RenderFileUploadControl.cpp"
index 9b41ae3..d0ea480 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore {
 using namespace SVGNames;
 
 RenderSVGGradientStop::RenderSVGGradientStop(SVGStopElement* element)
-    : RenderObject(element)
+    : RenderElement(element)
 {
 }
 
@@ -71,7 +71,7 @@ void RenderSVGGradientStop::layout()
 
 SVGGradientElement* RenderSVGGradientStop::gradientElement() const
 {
-    ContainerNode* parentNode = node()->parentNode();
+    ContainerNode* parentNode = element()->parentNode();
     if (parentNode->hasTagName(linearGradientTag) || parentNode->hasTagName(radialGradientTag))
         return toSVGGradientElement(parentNode);
     return 0;
index 64ba356..3bf1548 100644 (file)
@@ -22,7 +22,7 @@
 #define RenderSVGGradientStop_h
 
 #if ENABLE(SVG)
-#include "RenderObject.h"
+#include "RenderElement.h"
 
 namespace WebCore {
     
@@ -30,7 +30,7 @@ class SVGGradientElement;
 class SVGStopElement;
 
 // This class exists mostly so we can hear about gradient stop style changes
-class RenderSVGGradientStop FINAL : public RenderObject {
+class RenderSVGGradientStop FINAL : public RenderElement {
 public:
     RenderSVGGradientStop(SVGStopElement*);
     virtual ~RenderSVGGradientStop();
index c1756e1..92bfe94 100644 (file)
@@ -43,7 +43,7 @@
 namespace WebCore {
 
 RenderSVGModelObject::RenderSVGModelObject(SVGElement& element)
-    : RenderObject(&element)
+    : RenderElement(&element)
     , m_hasSVGShadow(false)
 {
 }
index 6683eff..cfdaeb2 100644 (file)
@@ -33,7 +33,7 @@
 
 #if ENABLE(SVG)
 
-#include "RenderObject.h"
+#include "RenderElement.h"
 #include "SVGElement.h"
 #include "SVGRenderSupport.h"
 
@@ -46,7 +46,7 @@ namespace WebCore {
 
 class SVGElement;
 
-class RenderSVGModelObject : public RenderObject {
+class RenderSVGModelObject : public RenderElement {
 public:
     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE;
     virtual void computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect&, bool fixed = false) const OVERRIDE FINAL;
@@ -67,7 +67,7 @@ public:
     bool hasSVGShadow() const { return m_hasSVGShadow; }
     void setHasSVGShadow(bool hasShadow) { m_hasSVGShadow = hasShadow; }
 
-    SVGElement& element() const { return *toSVGElement(RenderObject::node()); }
+    SVGElement& element() const { return *toSVGElement(RenderElement::element()); }
 
 protected:
     explicit RenderSVGModelObject(SVGElement&);
@@ -75,8 +75,6 @@ protected:
     virtual void willBeDestroyed() OVERRIDE;
 
 private:
-    void node() const WTF_DELETED_FUNCTION;
-
     // This method should never be called, SVG uses a different nodeAtPoint method
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
     virtual void absoluteFocusRingQuads(Vector<FloatQuad>&) OVERRIDE FINAL;
index 583e5c6..0741a08 100644 (file)
@@ -624,7 +624,7 @@ void writeSVGGradientStop(TextStream& ts, const RenderSVGGradientStop& stop, int
 {
     writeStandardPrefix(ts, stop, indent);
 
-    SVGStopElement* stopElement = toSVGStopElement(toSVGElement(stop.node()));
+    SVGStopElement* stopElement = toSVGStopElement(toSVGElement(stop.element()));
     ASSERT(stopElement);
 
     RenderStyle* style = stop.style();