Title: [112830] trunk/Source/WebCore
- Revision
- 112830
- Author
- tk...@chromium.org
- Date
- 2012-04-01 22:07:53 -0700 (Sun, 01 Apr 2012)
Log Message
Fix some problems of text field decoration
https://bugs.webkit.org/show_bug.cgi?id=82693
Reviewed by Dimitri Glazkov.
- Fix a problem that decorations are not removed when the input type is
changed.
- Add a comment to the 'willDetach' callback.
No new tests because the behavior changes are not visible yet.
* GNUMakefile.list.am: Add HTMLShadowElement.*.
* html/InputType.cpp:
(WebCore::InputType::destroyShadowSubtree):
Remove all of ShadowRoot contents, and add a <shadow> element to each of
them. We don't remove ShadowRoots from the tree because it's not
supported well.
* html/shadow/TextFieldDecorationElement.cpp:
(getDecorationRootAndDecoratedRoot): A helper function for decorate().
If the input element has a ShadowRoot with single <shadow> child, we
don't create new ShadowRoot and reuse it.
(WebCore::TextFieldDecorationElement::decorate):
Use getDecorationRootAndDecoratedRoot().
* html/shadow/TextFieldDecorationElement.h:
(TextFieldDecorator): Add a comment to willDetach().
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (112829 => 112830)
--- trunk/Source/WebCore/ChangeLog 2012-04-02 04:48:35 UTC (rev 112829)
+++ trunk/Source/WebCore/ChangeLog 2012-04-02 05:07:53 UTC (rev 112830)
@@ -1,3 +1,31 @@
+2012-03-29 Kent Tamura <tk...@chromium.org>
+
+ Fix some problems of text field decoration
+ https://bugs.webkit.org/show_bug.cgi?id=82693
+
+ Reviewed by Dimitri Glazkov.
+
+ - Fix a problem that decorations are not removed when the input type is
+ changed.
+ - Add a comment to the 'willDetach' callback.
+
+ No new tests because the behavior changes are not visible yet.
+
+ * GNUMakefile.list.am: Add HTMLShadowElement.*.
+ * html/InputType.cpp:
+ (WebCore::InputType::destroyShadowSubtree):
+ Remove all of ShadowRoot contents, and add a <shadow> element to each of
+ them. We don't remove ShadowRoots from the tree because it's not
+ supported well.
+ * html/shadow/TextFieldDecorationElement.cpp:
+ (getDecorationRootAndDecoratedRoot): A helper function for decorate().
+ If the input element has a ShadowRoot with single <shadow> child, we
+ don't create new ShadowRoot and reuse it.
+ (WebCore::TextFieldDecorationElement::decorate):
+ Use getDecorationRootAndDecoratedRoot().
+ * html/shadow/TextFieldDecorationElement.h:
+ (TextFieldDecorator): Add a comment to willDetach().
+
2012-04-01 Li Yin <li....@intel.com>
[WebSocket]Reserved bits test case should cover both extension and no-extension scenarios
Modified: trunk/Source/WebCore/GNUmakefile.list.am (112829 => 112830)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-04-02 04:48:35 UTC (rev 112829)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-04-02 05:07:53 UTC (rev 112830)
@@ -904,6 +904,7 @@
$(WebCore)/html/canvas/WebGLUniformLocation.idl \
$(WebCore)/html/canvas/WebGLVertexArrayObjectOES.idl \
$(WebCore)/html/shadow/HTMLContentElement.idl \
+ $(WebCore)/html/shadow/HTMLShadowElement.idl \
$(WebCore)/html/track/TextTrack.idl \
$(WebCore)/html/track/TextTrackCue.idl \
$(WebCore)/html/track/TextTrackCueList.idl \
@@ -2475,6 +2476,8 @@
Source/WebCore/html/shadow/HTMLContentElement.h \
Source/WebCore/html/shadow/HTMLContentSelector.cpp \
Source/WebCore/html/shadow/HTMLContentSelector.h \
+ Source/WebCore/html/shadow/HTMLShadowElement.cpp \
+ Source/WebCore/html/shadow/HTMLShadowElement.h \
Source/WebCore/html/shadow/InsertionPoint.cpp \
Source/WebCore/html/shadow/InsertionPoint.h \
Source/WebCore/html/shadow/MediaControls.cpp \
Modified: trunk/Source/WebCore/html/InputType.cpp (112829 => 112830)
--- trunk/Source/WebCore/html/InputType.cpp 2012-04-02 04:48:35 UTC (rev 112829)
+++ trunk/Source/WebCore/html/InputType.cpp 2012-04-02 05:07:53 UTC (rev 112830)
@@ -41,6 +41,7 @@
#include "FormDataList.h"
#include "HTMLFormElement.h"
#include "HTMLInputElement.h"
+#include "HTMLShadowElement.h"
#include "HiddenInputType.h"
#include "ImageInputType.h"
#include "KeyboardEvent.h"
@@ -70,6 +71,7 @@
namespace WebCore {
+using namespace HTMLNames;
using namespace std;
typedef PassOwnPtr<InputType> (*InputTypeFactoryFunction)(HTMLInputElement*);
@@ -382,8 +384,17 @@
if (!element()->hasShadowRoot())
return;
- if (ShadowRoot* root = element()->shadowTree()->oldestShadowRoot())
+ ShadowRoot* root = element()->shadowTree()->oldestShadowRoot();
+ ASSERT(root);
+ root->removeAllChildren();
+
+ // It's ok to clear contents of all other ShadowRoots because they must have
+ // been created by TextFieldDecorationElement, and we don't allow adding
+ // AuthorShadowRoot to HTMLInputElement.
+ while ((root = root->youngerShadowRoot())) {
root->removeAllChildren();
+ root->appendChild(HTMLShadowElement::create(shadowTag, element()->document()));
+ }
}
double InputType::parseToDouble(const String&, double defaultValue) const
Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp (112829 => 112830)
--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-04-02 04:48:35 UTC (rev 112829)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-04-02 05:07:53 UTC (rev 112830)
@@ -66,16 +66,35 @@
return adoptRef(new TextFieldDecorationElement(document, decorator));
}
+static inline void getDecorationRootAndDecoratedRoot(HTMLInputElement* input, ShadowRoot*& decorationRoot, ShadowRoot*& decoratedRoot)
+{
+ ShadowRoot* existingRoot = input->shadowTree()->youngestShadowRoot();
+ ShadowRoot* newRoot = 0;
+ while (existingRoot->childNodeCount() == 1 && existingRoot->firstChild()->hasTagName(shadowTag)) {
+ newRoot = existingRoot;
+ existingRoot = existingRoot->olderShadowRoot();
+ ASSERT(existingRoot);
+ }
+ if (newRoot)
+ newRoot->removeChild(newRoot->firstChild());
+ else
+ newRoot = ShadowRoot::create(input, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION).get();
+ decorationRoot = newRoot;
+ decoratedRoot = existingRoot;
+}
+
void TextFieldDecorationElement::decorate(HTMLInputElement* input)
{
ASSERT(input);
- ShadowRoot* existingRoot = input->shadowTree()->youngestShadowRoot();
- RefPtr<ShadowRoot> newRoot = ShadowRoot::create(input, ShadowRoot::CreatingUserAgentShadowRoot, ASSERT_NO_EXCEPTION);
+ ShadowRoot* existingRoot;
+ ShadowRoot* decorationRoot;
+ getDecorationRootAndDecoratedRoot(input, decorationRoot, existingRoot);
+ ASSERT(decorationRoot);
+ ASSERT(existingRoot);
RefPtr<HTMLDivElement> box = HTMLDivElement::create(input->document());
- newRoot->appendChild(box);
+ decorationRoot->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()));
Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h (112829 => 112830)
--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h 2012-04-02 04:48:35 UTC (rev 112829)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h 2012-04-02 05:07:53 UTC (rev 112830)
@@ -52,6 +52,9 @@
virtual CachedImage* imageForReadonlyState() = 0;
virtual void handleClick(HTMLInputElement*) = 0;
+ // This function is called just before detaching the decoration. It must not
+ // call functions which updating state of the specified HTMLInputElement
+ // object.
virtual void willDetach(HTMLInputElement*) = 0;
virtual ~TextFieldDecorator();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes