Reduce constructor copypasta in RenderText and RenderElement.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 May 2014 06:44:35 +0000 (06:44 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 May 2014 06:44:35 +0000 (06:44 +0000)
<https://webkit.org/b/133056>

Use delegating constructors to remove duplicated initializer lists
from the constructors of RenderText and RenderElement.

Reviewed by Anders Carlsson.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::RenderElement):
* rendering/RenderElement.h:
* rendering/RenderText.cpp:
(WebCore::RenderText::RenderText):
* rendering/RenderText.h:

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderText.h

index 8448bd3..bfbb890 100644 (file)
@@ -1,3 +1,20 @@
+2014-05-18  Andreas Kling  <akling@apple.com>
+
+        Reduce constructor copypasta in RenderText and RenderElement.
+        <https://webkit.org/b/133056>
+
+        Use delegating constructors to remove duplicated initializer lists
+        from the constructors of RenderText and RenderElement.
+
+        Reviewed by Anders Carlsson.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::RenderElement):
+        * rendering/RenderElement.h:
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::RenderText):
+        * rendering/RenderText.h:
+
 2014-05-18  Brent Fulgham  <bfulgham@apple.com>
 
         Crash during scroll when latched
index d2d8950..ad8a4a3 100644 (file)
@@ -76,9 +76,9 @@ static HashMap<const RenderObject*, ControlStates*>& controlStatesRendererMap()
     static NeverDestroyed<HashMap<const RenderObject*, ControlStates*>> map;
     return map;
 }
-    
-RenderElement::RenderElement(Element& element, PassRef<RenderStyle> style, unsigned baseTypeFlags)
-    : RenderObject(element)
+
+inline RenderElement::RenderElement(ContainerNode& elementOrDocument, PassRef<RenderStyle> style, unsigned baseTypeFlags)
+    : RenderObject(elementOrDocument)
     , m_baseTypeFlags(baseTypeFlags)
     , m_ancestorLineBoxDirty(false)
     , m_hasInitializedStyle(false)
@@ -91,17 +91,13 @@ RenderElement::RenderElement(Element& element, PassRef<RenderStyle> style, unsig
 {
 }
 
+RenderElement::RenderElement(Element& element, PassRef<RenderStyle> style, unsigned baseTypeFlags)
+    : RenderElement(static_cast<ContainerNode&>(element), std::move(style), baseTypeFlags)
+{
+}
+
 RenderElement::RenderElement(Document& document, PassRef<RenderStyle> style, unsigned baseTypeFlags)
-    : RenderObject(document)
-    , m_baseTypeFlags(baseTypeFlags)
-    , m_ancestorLineBoxDirty(false)
-    , m_hasInitializedStyle(false)
-    , m_renderInlineAlwaysCreatesLineBoxes(false)
-    , m_renderBoxNeedsLazyRepaint(false)
-    , m_hasPausedImageAnimations(false)
-    , m_firstChild(nullptr)
-    , m_lastChild(nullptr)
-    , m_style(std::move(style))
+    : RenderElement(static_cast<ContainerNode&>(document), std::move(style), baseTypeFlags)
 {
 }
 
index 97eb4c7..2a873eb 100644 (file)
@@ -199,6 +199,7 @@ protected:
     static void addControlStatesForRenderer(const RenderObject*, ControlStates*);
 
 private:
+    RenderElement(ContainerNode&, PassRef<RenderStyle>, unsigned baseTypeFlags);
     void node() const = delete;
     void nonPseudoNode() const = delete;
     void generatingNode() const = delete;
index 9d0eb25..eeec533 100644 (file)
@@ -153,8 +153,8 @@ void makeCapitalized(String* string, UChar previous)
     *string = result.toString();
 }
 
-RenderText::RenderText(Text& textNode, const String& text)
-    : RenderObject(textNode)
+inline RenderText::RenderText(Node& node, const String& text)
+    : RenderObject(node)
     , m_hasTab(false)
     , m_linesDirty(false)
     , m_containsReversedText(false)
@@ -177,28 +177,14 @@ RenderText::RenderText(Text& textNode, const String& text)
     view().frameView().incrementVisuallyNonEmptyCharacterCount(textLength());
 }
 
+RenderText::RenderText(Text& textNode, const String& text)
+    : RenderText(static_cast<Node&>(textNode), text)
+{
+}
+
 RenderText::RenderText(Document& document, const String& text)
-    : RenderObject(document)
-    , m_hasTab(false)
-    , m_linesDirty(false)
-    , m_containsReversedText(false)
-    , m_isAllASCII(text.containsOnlyASCII())
-    , m_knownToHaveNoOverflowAndNoFallbackFonts(false)
-    , m_useBackslashAsYenSymbol(false)
-    , m_originalTextDiffersFromRendered(false)
-#if ENABLE(IOS_TEXT_AUTOSIZING)
-    , m_candidateComputedTextSize(0)
-#endif
-    , m_minWidth(-1)
-    , m_maxWidth(-1)
-    , m_beginMinWidth(0)
-    , m_endMinWidth(0)
-    , m_text(text)
+    : RenderText(static_cast<Node&>(document), text)
 {
-    ASSERT(!m_text.isNull());
-    setIsText();
-    m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath();
-    view().frameView().incrementVisuallyNonEmptyCharacterCount(textLength());
 }
 
 RenderText::~RenderText()
index d4fdf44..b107989 100644 (file)
@@ -162,6 +162,8 @@ protected:
     virtual UChar previousCharacter() const;
 
 private:
+    RenderText(Node&, const String&);
+
     virtual bool canHaveChildren() const override final { return false; }
 
     void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow&);