Title: [112503] trunk/Source/WebCore
Revision
112503
Author
[email protected]
Date
2012-03-28 23:00:23 -0700 (Wed, 28 Mar 2012)

Log Message

Add TextFieldDecorationElement::decorate()
https://bugs.webkit.org/show_bug.cgi?id=82572

Reviewed by Hajime Morita.

This change will be needed for Bug 82143.
No new tests because of no behavior changes yet. This code change
doesn't affect non-Chromium ports for now.

* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::create):
Remove unnecessary assertion. We should allow multiple UA shadow roots.
* html/shadow/TextFieldDecorationElement.cpp:
(WebCore::TextFieldDecorationElement::decorate):
Added.
This function adds another ShadowRoot, and it contains one flexible box container.
The container contains existin ShadowRoot content and the decoration element.
* html/shadow/TextFieldDecorationElement.h:
(TextFieldDecorationElement): Add the declaration of decorate().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (112502 => 112503)


--- trunk/Source/WebCore/ChangeLog	2012-03-29 05:47:18 UTC (rev 112502)
+++ trunk/Source/WebCore/ChangeLog	2012-03-29 06:00:23 UTC (rev 112503)
@@ -1,3 +1,25 @@
+2012-03-28  Kent Tamura  <[email protected]>
+
+        Add TextFieldDecorationElement::decorate()
+        https://bugs.webkit.org/show_bug.cgi?id=82572
+
+        Reviewed by Hajime Morita.
+
+        This change will be needed for Bug 82143.
+        No new tests because of no behavior changes yet. This code change
+        doesn't affect non-Chromium ports for now.
+
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::create):
+        Remove unnecessary assertion. We should allow multiple UA shadow roots.
+        * html/shadow/TextFieldDecorationElement.cpp:
+        (WebCore::TextFieldDecorationElement::decorate):
+        Added.
+        This function adds another ShadowRoot, and it contains one flexible box container.
+        The container contains existin ShadowRoot content and the decoration element.
+        * html/shadow/TextFieldDecorationElement.h:
+        (TextFieldDecorationElement): Add the declaration of decorate().
+
 2012-03-28  Vineet Chaudhary  <[email protected]>
 
         Consider removal of removes jsNull()/v8::Null() from JSInternalsCustom.cpp/V8InternalsCustom.cpp

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (112502 => 112503)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-03-29 05:47:18 UTC (rev 112502)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-03-29 06:00:23 UTC (rev 112503)
@@ -113,7 +113,6 @@
         return 0;
     }
 
-    ASSERT(purpose != CreatingUserAgentShadowRoot || !element->hasShadowRoot());
     RefPtr<ShadowRoot> shadowRoot = adoptRef(new ShadowRoot(element->document()));
 
     ec = 0;

Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp (112502 => 112503)


--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp	2012-03-29 05:47:18 UTC (rev 112502)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp	2012-03-29 06:00:23 UTC (rev 112503)
@@ -31,10 +31,15 @@
 #include "config.h"
 #include "TextFieldDecorationElement.h"
 
+#include "CSSPropertyNames.h"
+#include "CSSValueKeywords.h"
 #include "Event.h"
 #include "HTMLInputElement.h"
+#include "HTMLShadowElement.h"
 #include "NodeRenderStyle.h"
 #include "RenderImage.h"
+#include "ShadowRoot.h"
+#include "ShadowTree.h"
 
 namespace WebCore {
 
@@ -61,6 +66,24 @@
     return adoptRef(new TextFieldDecorationElement(document, decorator));
 }
 
+void TextFieldDecorationElement::decorate(HTMLInputElement* input)
+{
+    ASSERT(input);
+    ShadowRoot* existingRoot = input->shadowTree()->youngestShadowRoot();
+    RefPtr<ShadowRoot> newRoot = ShadowRoot::create(input, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
+    RefPtr<HTMLDivElement> box = HTMLDivElement::create(input->document());
+    newRoot->appendChild(box);
+    box->setInlineStyleProperty(CSSPropertyDisplay, CSSValueWebkitBox);
+    box->setInlineStyleProperty(CSSPropertyWebkitBoxAlign, CSSValueCenter);
+    ASSERT(existingRoot);
+    ASSERT(existingRoot->childNodeCount() == 1);
+    toHTMLElement(existingRoot->firstChild())->setInlineStyleProperty(CSSPropertyWebkitBoxFlex, 1.0, CSSPrimitiveValue::CSS_NUMBER);
+    box->appendChild(HTMLShadowElement::create(HTMLNames::shadowTag, input->document()));
+
+    setInlineStyleProperty(CSSPropertyWebkitBoxFlex, 0.0, CSSPrimitiveValue::CSS_NUMBER);
+    box->appendChild(this);
+}
+
 inline HTMLInputElement* TextFieldDecorationElement::hostInput()
 {
     ASSERT(shadowAncestorNode());

Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h (112502 => 112503)


--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h	2012-03-29 05:47:18 UTC (rev 112502)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h	2012-03-29 06:00:23 UTC (rev 112503)
@@ -63,6 +63,7 @@
 public:
     static PassRefPtr<TextFieldDecorationElement> create(Document*, TextFieldDecorator*);
     TextFieldDecorator* textFieldDecorator() { return m_textFieldDecorator; }
+    void decorate(HTMLInputElement*);
 
 private:
     TextFieldDecorationElement(Document*, TextFieldDecorator*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to