Unreviewed, rolling out r129086.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2012 09:22:51 +0000 (09:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2012 09:22:51 +0000 (09:22 +0000)
http://trac.webkit.org/changeset/129086
https://bugs.webkit.org/show_bug.cgi?id=97312

Broke input rendering (Requested by shinyak on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-09-21

* html/BaseButtonInputType.cpp:
(WebCore):
* html/BaseButtonInputType.h:
(WebCore::BaseButtonInputType::BaseButtonInputType):
(BaseButtonInputType):
* html/FileInputType.cpp:
(WebCore::UploadButtonElement::create):
(WebCore::UploadButtonElement::createForMultiple):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::parseAttribute):
* html/InputType.cpp:
* html/InputType.h:
(InputType):
* rendering/RenderButton.cpp:
(WebCore::RenderButton::RenderButton):
(WebCore::RenderButton::styleDidChange):
(WebCore::RenderButton::updateFromElement):
(WebCore):
(WebCore::RenderButton::setText):
(WebCore::RenderButton::text):
* rendering/RenderButton.h:
(RenderButton):

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

Source/WebCore/ChangeLog
Source/WebCore/html/BaseButtonInputType.cpp
Source/WebCore/html/BaseButtonInputType.h
Source/WebCore/html/FileInputType.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/rendering/RenderButton.cpp
Source/WebCore/rendering/RenderButton.h

index 70a3e9f..31ecc4e 100644 (file)
@@ -1,3 +1,34 @@
+2012-09-21  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r129086.
+        http://trac.webkit.org/changeset/129086
+        https://bugs.webkit.org/show_bug.cgi?id=97312
+
+        Broke input rendering (Requested by shinyak on #webkit).
+
+        * html/BaseButtonInputType.cpp:
+        (WebCore):
+        * html/BaseButtonInputType.h:
+        (WebCore::BaseButtonInputType::BaseButtonInputType):
+        (BaseButtonInputType):
+        * html/FileInputType.cpp:
+        (WebCore::UploadButtonElement::create):
+        (WebCore::UploadButtonElement::createForMultiple):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::parseAttribute):
+        * html/InputType.cpp:
+        * html/InputType.h:
+        (InputType):
+        * rendering/RenderButton.cpp:
+        (WebCore::RenderButton::RenderButton):
+        (WebCore::RenderButton::styleDidChange):
+        (WebCore::RenderButton::updateFromElement):
+        (WebCore):
+        (WebCore::RenderButton::setText):
+        (WebCore::RenderButton::text):
+        * rendering/RenderButton.h:
+        (RenderButton):
+
 2012-09-21  Kihong Kwon  <kihong.kwon@samsung.com>
 
         Remove useless class prototypes from Vibration.h
index d1ed27b..5fde8d7 100644 (file)
 #include "HTMLNames.h"
 #include "KeyboardEvent.h"
 #include "RenderButton.h"
-#include "RenderTextFragment.h"
-#include "ShadowRoot.h"
-#include "Text.h"
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
-class TextForButtonInputType : public Text {
-public:
-    static PassRefPtr<TextForButtonInputType> create(Document*, const String&);
-
-private:
-    TextForButtonInputType(Document*, const String&);
-    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;
-};
-
-PassRefPtr<TextForButtonInputType> TextForButtonInputType::create(Document* document, const String& data)
-{
-    return adoptRef(new TextForButtonInputType(document, data));
-}
-
-TextForButtonInputType::TextForButtonInputType(Document* document, const String& data)
-    : Text(document, data)
-{
-}
-
-RenderObject* TextForButtonInputType::createRenderer(RenderArena* arena, RenderStyle*)
-{
-    return new (arena) RenderTextFragment(document(), dataImpl());
-}
-
-BaseButtonInputType::BaseButtonInputType(HTMLInputElement* element)
-    : BaseClickableWithKeyInputType(element)
-{
-}
-
-void BaseButtonInputType::createShadowSubtree()
-{
-    ASSERT(element()->userAgentShadowRoot());
-
-    RefPtr<TextForButtonInputType> text = TextForButtonInputType::create(element()->document(), defaultValue());
-    element()->userAgentShadowRoot()->appendChild(text);
-}
-
-void BaseButtonInputType::destroyShadowSubtree()
-{
-    InputType::destroyShadowSubtree();
-}
-
-void BaseButtonInputType::valueAttributeChanged()
-{
-    String value = element()->valueWithDefault();
-    toText(element()->userAgentShadowRoot()->firstChild())->setData(value, ASSERT_NO_EXCEPTION);
-}
-
 bool BaseButtonInputType::shouldSaveAndRestoreFormControlState() const
 {
     return false;
index 3b8384c..4dfbb04 100644 (file)
@@ -38,14 +38,9 @@ namespace WebCore {
 // Base of button, file, image, reset, and submit types.
 class BaseButtonInputType : public BaseClickableWithKeyInputType {
 protected:
-    BaseButtonInputType(HTMLInputElement*);
+    BaseButtonInputType(HTMLInputElement* element) : BaseClickableWithKeyInputType(element) { }
 
 private:
-    virtual void createShadowSubtree() OVERRIDE;
-    virtual void destroyShadowSubtree() OVERRIDE;
-
-    virtual void valueAttributeChanged() OVERRIDE;
-
     virtual bool shouldSaveAndRestoreFormControlState() const OVERRIDE;
     virtual bool appendFormData(FormDataList&, bool) const OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
index cc19f2a..89fcc87 100644 (file)
@@ -62,7 +62,6 @@ private:
 PassRefPtr<UploadButtonElement> UploadButtonElement::create(Document* document)
 {
     RefPtr<UploadButtonElement> button = adoptRef(new UploadButtonElement(document));
-    button->createShadowSubtree();
     button->setType("button");
     button->setValue(fileButtonChooseFileLabel());
     return button.release();
@@ -71,7 +70,6 @@ PassRefPtr<UploadButtonElement> UploadButtonElement::create(Document* document)
 PassRefPtr<UploadButtonElement> UploadButtonElement::createForMultiple(Document* document)
 {
     RefPtr<UploadButtonElement> button = adoptRef(new UploadButtonElement(document));
-    button->createShadowSubtree();
     button->setType("button");
     button->setValue(fileButtonChooseMultipleFilesLabel());
     return button.release();
index 4cfc2b7..d1ea76c 100644 (file)
@@ -677,7 +677,6 @@ void HTMLInputElement::parseAttribute(const Attribute& attribute)
             updatePlaceholderVisibility(false);
             setNeedsStyleRecalc();
         }
-        m_inputType->valueAttributeChanged();
         setFormControlValueMatchesRenderer(false);
         setNeedsValidityCheck();
         m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress;
index 1a078f2..38d79ee 100644 (file)
@@ -889,10 +889,6 @@ void InputType::updatePlaceholderText()
 {
 }
 
-void InputType::valueAttributeChanged()
-{
-}
-
 void InputType::multipleAttributeChanged()
 {
 }
index 29d8cc3..87a4c12 100644 (file)
@@ -278,7 +278,6 @@ public:
     virtual String fixedPlaceholder();
     virtual void updateInnerTextValue();
     virtual void updatePlaceholderText();
-    virtual void valueAttributeChanged();
     virtual void multipleAttributeChanged();
     virtual void disabledAttributeChanged();
     virtual void readonlyAttributeChanged();
index c59c822..7103e6e 100644 (file)
@@ -35,6 +35,7 @@ using namespace HTMLNames;
 
 RenderButton::RenderButton(Node* node)
     : RenderDeprecatedFlexibleBox(node)
+    , m_buttonText(0)
     , m_inner(0)
     , m_default(false)
 {
@@ -82,6 +83,8 @@ void RenderButton::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
 {
     RenderBlock::styleDidChange(diff, oldStyle);
 
+    if (m_buttonText)
+        m_buttonText->setStyle(style());
     if (m_inner) // RenderBlock handled updating the anonymous block's style.
         setupInnerStyle(m_inner->style());
 
@@ -105,6 +108,39 @@ void RenderButton::setupInnerStyle(RenderStyle* innerStyle)
     innerStyle->setBoxOrient(style()->boxOrient());
 }
 
+void RenderButton::updateFromElement()
+{
+    // If we're an input element, we may need to change our button text.
+    if (node()->hasTagName(inputTag)) {
+        HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+        String value = input->valueWithDefault();
+        setText(value);
+    }
+}
+
+void RenderButton::setText(const String& str)
+{
+    if (str.isEmpty()) {
+        if (m_buttonText) {
+            m_buttonText->destroy();
+            m_buttonText = 0;
+        }
+    } else {
+        if (m_buttonText)
+            m_buttonText->setText(str.impl());
+        else {
+            m_buttonText = new (renderArena()) RenderTextFragment(document(), str.impl());
+            m_buttonText->setStyle(style());
+            addChild(m_buttonText);
+        }
+    }
+}
+
+String RenderButton::text() const
+{
+    return m_buttonText ? m_buttonText->text() : 0;
+}
+
 bool RenderButton::canHaveGeneratedChildren() const
 {
     // Input elements can't have generated children, but button elements can. We'll
index 9dde453..5be62b0 100644 (file)
@@ -48,6 +48,7 @@ public:
     virtual bool createsAnonymousWrapper() const { return true; }
 
     void setupInnerStyle(RenderStyle*);
+    virtual void updateFromElement();
 
     virtual void updateBeforeAfterContent(PseudoId);
 
@@ -55,6 +56,9 @@ public:
     virtual bool hasControlClip() const { return true; }
     virtual LayoutRect controlClipRect(const LayoutPoint&) const;
 
+    void setText(const String&);
+    String text() const;
+
 private:
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
@@ -65,7 +69,9 @@ private:
 
     void timerFired(Timer<RenderButton>*);
 
+    RenderTextFragment* m_buttonText;
     RenderBlock* m_inner;
+
     OwnPtr<Timer<RenderButton> > m_timer;
     bool m_default;
 };