Diff
Modified: trunk/Source/WebCore/ChangeLog (118600 => 118601)
--- trunk/Source/WebCore/ChangeLog 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebCore/ChangeLog 2012-05-26 02:20:40 UTC (rev 118601)
@@ -1,3 +1,18 @@
+2012-05-25 Garrett Casto <[email protected]>
+
+ Allow WebTextFieldDecoratorClient to see applied decorations.
+ https://bugs.webkit.org/show_bug.cgi?id=86557
+
+ Reviewed by Kent Tamura.
+
+ * html/shadow/TextFieldDecorationElement.cpp:
+ (WebCore::TextFieldDecorationElement::fromShadowRoot): A function
+ that will extract a TextFielDecorationElement from a ShadowRoot, if
+ there is one.
+ * html/shadow/TextFieldDecorationElement.h:
+ (WebCore):
+ (TextFieldDecorator):
+
2012-05-25 Tony Chang <[email protected]>
implement new negative flexing algorithm
Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp (118600 => 118601)
--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-05-26 02:20:40 UTC (rev 118601)
@@ -66,6 +66,16 @@
return adoptRef(new TextFieldDecorationElement(document, decorator));
}
+TextFieldDecorationElement* TextFieldDecorationElement::fromShadowRoot(ShadowRoot* shadowRoot)
+{
+ if (!shadowRoot->firstChild()
+ || !shadowRoot->firstChild()->lastChild()
+ || !shadowRoot->firstChild()->lastChild()->isElementNode()
+ || !toElement(shadowRoot->firstChild()->lastChild())->isTextFieldDecoration())
+ return 0;
+ return toTextFieldDecorationElement(shadowRoot->firstChild()->lastChild());
+}
+
static inline void getDecorationRootAndDecoratedRoot(HTMLInputElement* input, ShadowRoot*& decorationRoot, ShadowRoot*& decoratedRoot)
{
ShadowRoot* existingRoot = input->youngestShadowRoot();
@@ -83,7 +93,7 @@
decoratedRoot = existingRoot;
}
-void TextFieldDecorationElement::decorate(HTMLInputElement* input)
+void TextFieldDecorationElement::decorate(HTMLInputElement* input, bool visible)
{
ASSERT(input);
ShadowRoot* existingRoot;
@@ -99,7 +109,7 @@
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);
+ setInlineStyleProperty(CSSPropertyDisplay, visible ? CSSValueBlock : CSSValueNone);
box->appendChild(this);
}
Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h (118600 => 118601)
--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h 2012-05-26 02:20:40 UTC (rev 118601)
@@ -37,6 +37,7 @@
class CachedImage;
class HTMLInputElement;
+class ShadowRoot;
// A TextFieldDecorator object must live until all of text fields which were
// decorated by it die.
@@ -45,6 +46,7 @@
// Returns true if this TextFieldDecorator wants to add a
// decoration to the specified text field.
virtual bool willAddDecorationTo(HTMLInputElement*) = 0;
+ virtual bool visibleByDefault() = 0;
// A TextFieldDecorator object should own the CachedImage objects.
virtual CachedImage* imageForNormalState() = 0;
@@ -65,8 +67,9 @@
class TextFieldDecorationElement : public HTMLDivElement {
public:
static PassRefPtr<TextFieldDecorationElement> create(Document*, TextFieldDecorator*);
+ static TextFieldDecorationElement* fromShadowRoot(ShadowRoot*);
TextFieldDecorator* textFieldDecorator() { return m_textFieldDecorator; }
- void decorate(HTMLInputElement*);
+ void decorate(HTMLInputElement*, bool visible);
private:
TextFieldDecorationElement(Document*, TextFieldDecorator*);
Modified: trunk/Source/WebKit/chromium/ChangeLog (118600 => 118601)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-05-26 02:20:40 UTC (rev 118601)
@@ -1,3 +1,21 @@
+2012-05-25 Garrett Casto <[email protected]>
+
+ Allow WebTextFieldDecoratorClient to see applied decorations.
+ https://bugs.webkit.org/show_bug.cgi?id=86557
+
+ Reviewed by Kent Tamura.
+
+ * WebKit.gyp: Added new files.
+ * public/WebInputElement.h:
+ (WebKit::WebInputElement::decorationElementFor): Returns the
+ WebElement attached to the WebInputElement by the given
+ WebTextFieldDecoratorClient, if one exists.
+ * src/TextFieldDecoratorImpl.cpp:
+ (WebKit):
+ * src/TextFieldDecoratorImpl.h:
+ (TextFieldDecoratorImpl::decoratorClient): Get the
+ WebTextFieldDecoratorClient owned by this object.
+
2012-05-25 Mihai Parparita <[email protected]>
Allow synchronous XHRs to be disabled in documents
Modified: trunk/Source/WebKit/chromium/WebKit.gyp (118600 => 118601)
--- trunk/Source/WebKit/chromium/WebKit.gyp 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/WebKit.gyp 2012-05-26 02:20:40 UTC (rev 118601)
@@ -649,6 +649,7 @@
'src/WebTextRun.cpp',
'src/WebURLLoadTiming.cpp',
'src/WebScopedUserGesture.cpp',
+ 'src/WebTextFieldDecoratorClient.cpp',
'src/WebUserMediaRequest.cpp',
'src/WebVideoLayer.cpp',
'src/WebViewImpl.cpp',
Modified: trunk/Source/WebKit/chromium/public/WebInputElement.h (118600 => 118601)
--- trunk/Source/WebKit/chromium/public/WebInputElement.h 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/public/WebInputElement.h 2012-05-26 02:20:40 UTC (rev 118601)
@@ -40,6 +40,7 @@
namespace WebKit {
class WebNodeCollection;
+ class WebTextFieldDecoratorClient;
// Provides readonly access to some properties of a DOM input element node.
class WebInputElement : public WebFormControlElement {
@@ -103,6 +104,9 @@
// Exposes the default value of the maxLength attribute.
WEBKIT_EXPORT static int defaultMaxLength();
+ // Return the decoration added by the specified decorator if one exists.
+ WEBKIT_EXPORT WebElement decorationElementFor(WebTextFieldDecoratorClient*);
+
#if WEBKIT_IMPLEMENTATION
WebInputElement(const WTF::PassRefPtr<WebCore::HTMLInputElement>&);
WebInputElement& operator=(const WTF::PassRefPtr<WebCore::HTMLInputElement>&);
Modified: trunk/Source/WebKit/chromium/public/WebTextFieldDecoratorClient.h (118600 => 118601)
--- trunk/Source/WebKit/chromium/public/WebTextFieldDecoratorClient.h 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/public/WebTextFieldDecoratorClient.h 2012-05-26 02:20:40 UTC (rev 118601)
@@ -33,6 +33,10 @@
#include "platform/WebCString.h"
+#if WEBKIT_IMPLEMENTATION
+namespace WebCore { class TextFieldDecorator; }
+#endif
+
namespace WebKit {
class WebInputElement;
@@ -43,6 +47,8 @@
// have a decoration icon. This function is called whenever a text field is
// created, and should not take much time.
virtual bool shouldAddDecorationTo(const WebInputElement&) = 0;
+ // Returns true if the decoration should be visible when it's created.
+ virtual bool visibleByDefault() = 0;
// Image resource name for the normal state. The image is stretched to
// font-size x font-size square. The function must return an existing
@@ -63,6 +69,10 @@
// state of WebKit objects.
virtual void willDetach(const WebInputElement&) = 0;
+#if WEBKIT_IMPLEMENTATION
+ bool isClientFor(WebCore::TextFieldDecorator*);
+#endif
+
virtual ~WebTextFieldDecoratorClient() { }
};
Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (118600 => 118601)
--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp 2012-05-26 02:20:40 UTC (rev 118601)
@@ -1037,7 +1037,7 @@
if (!decorators[i]->willAddDecorationTo(input))
continue;
RefPtr<TextFieldDecorationElement> decoration = TextFieldDecorationElement::create(input->document(), decorators[i].get());
- decoration->decorate(input);
+ decoration->decorate(input, decorators[i]->visibleByDefault());
}
}
Modified: trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.cpp (118600 => 118601)
--- trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.cpp 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.cpp 2012-05-26 02:20:40 UTC (rev 118601)
@@ -56,12 +56,22 @@
{
}
+WebTextFieldDecoratorClient* TextFieldDecoratorImpl::decoratorClient()
+{
+ return m_client;
+}
+
bool TextFieldDecoratorImpl::willAddDecorationTo(HTMLInputElement* input)
{
ASSERT(input);
return m_client->shouldAddDecorationTo(WebInputElement(input));
}
+bool TextFieldDecoratorImpl::visibleByDefault()
+{
+ return m_client->visibleByDefault();
+}
+
CachedImage* TextFieldDecoratorImpl::imageForNormalState()
{
if (!m_cachedImageForNormalState) {
Modified: trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.h (118600 => 118601)
--- trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.h 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.h 2012-05-26 02:20:40 UTC (rev 118601)
@@ -43,8 +43,11 @@
static PassOwnPtr<TextFieldDecoratorImpl> create(WebTextFieldDecoratorClient*);
virtual ~TextFieldDecoratorImpl();
+ WebTextFieldDecoratorClient* decoratorClient();
+
private:
virtual bool willAddDecorationTo(WebCore::HTMLInputElement*) OVERRIDE;
+ virtual bool visibleByDefault() OVERRIDE;
virtual WebCore::CachedImage* imageForNormalState() OVERRIDE;
virtual WebCore::CachedImage* imageForDisabledState() OVERRIDE;
virtual WebCore::CachedImage* imageForReadonlyState() OVERRIDE;
Modified: trunk/Source/WebKit/chromium/src/WebInputElement.cpp (118600 => 118601)
--- trunk/Source/WebKit/chromium/src/WebInputElement.cpp 2012-05-26 02:07:18 UTC (rev 118600)
+++ trunk/Source/WebKit/chromium/src/WebInputElement.cpp 2012-05-26 02:20:40 UTC (rev 118601)
@@ -31,11 +31,16 @@
#include "config.h"
#include "WebInputElement.h"
+#include "ElementShadow.h"
#include "HTMLDataListElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
+#include "ShadowRoot.h"
#include "TextControlInnerElements.h"
+#include "TextFieldDecorationElement.h"
+#include "TextFieldDecoratorImpl.h"
#include "WebNodeCollection.h"
+#include "WebTextFieldDecoratorClient.h"
#include "platform/WebString.h"
#include <wtf/PassRefPtr.h>
@@ -221,6 +226,18 @@
return HTMLInputElement::maximumLength;
}
+WebElement WebInputElement::decorationElementFor(WebTextFieldDecoratorClient* decoratorClient)
+{
+ ShadowRoot* shadowRoot = unwrap<HTMLInputElement>()->youngestShadowRoot();
+ while (shadowRoot) {
+ TextFieldDecorationElement* decoration = TextFieldDecorationElement::fromShadowRoot(shadowRoot);
+ if (decoration && decoratorClient->isClientFor(decoration->textFieldDecorator()))
+ return WebElement(decoration);
+ shadowRoot = shadowRoot->olderShadowRoot();
+ }
+ return WebElement();
+}
+
WebInputElement::WebInputElement(const PassRefPtr<HTMLInputElement>& elem)
: WebFormControlElement(elem)
{
Copied: trunk/Source/WebKit/chromium/src/WebTextFieldDecoratorClient.cpp (from rev 118600, trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.h) (0 => 118601)
--- trunk/Source/WebKit/chromium/src/WebTextFieldDecoratorClient.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/src/WebTextFieldDecoratorClient.cpp 2012-05-26 02:20:40 UTC (rev 118601)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebTextFieldDecoratorClient.h"
+
+#include "TextFieldDecorationElement.h"
+#include "TextFieldDecoratorImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebTextFieldDecoratorClient::isClientFor(TextFieldDecorator* decorator)
+{
+ return static_cast<TextFieldDecoratorImpl*>(decorator)->decoratorClient() == this;
+}
+
+} // namespace WebKit