Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: Source/WebCore/html/shadow/DateTimeEditElement.cpp

Issue 11557024: Merge 136808 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/html/shadow/DateTimeEditElement.h ('k') | Source/WebCore/html/shadow/DateTimeFieldElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/html/shadow/DateTimeEditElement.cpp
===================================================================
--- Source/WebCore/html/shadow/DateTimeEditElement.cpp (revision 137540)
+++ Source/WebCore/html/shadow/DateTimeEditElement.cpp (working copy)
@@ -33,10 +33,13 @@
#include "DateTimeFormat.h"
#include "DateTimeSymbolicFieldElement.h"
#include "EventHandler.h"
+#include "FontCache.h"
#include "HTMLNames.h"
#include "KeyboardEvent.h"
#include "MouseEvent.h"
#include "PlatformLocale.h"
+#include "RenderStyle.h"
+#include "StyleResolver.h"
#include "Text.h"
#include <wtf/DateMath.h>
#include <wtf/text/StringBuilder.h>
@@ -301,6 +304,7 @@
{
DEFINE_STATIC_LOCAL(AtomicString, dateTimeEditPseudoId, ("-webkit-datetime-edit"));
setShadowPseudoId(dateTimeEditPseudoId);
+ setHasCustomCallbacks();
}
DateTimeEditElement::~DateTimeEditElement()
@@ -329,6 +333,31 @@
return container.release();
}
+PassRefPtr<RenderStyle> DateTimeEditElement::customStyleForRenderer()
+{
+ // FIXME: This is a kind of layout. We might want to introduce new renderer.
+ FontCachePurgePreventer fontCachePurgePreventer;
+ RefPtr<RenderStyle> originalStyle = document()->styleResolver()->styleForElement(this);
+ RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
+ float width = 0;
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ if (!child->isElementNode())
+ continue;
+ Element* childElement = toElement(child);
+ if (childElement->isDateTimeFieldElement()) {
+ // We need to pass the Font of this element because child elements
+ // can't resolve inherited style at this timing.
+ width += static_cast<DateTimeFieldElement*>(childElement)->maximumWidth(style->font());
+ } else {
+ // ::-webkit-datetime-edit-text case. It has no
+ // border/padding/margin in html.css.
+ width += style->font().width(childElement->textContent());
+ }
+ }
+ style->setMinWidth(Length(ceilf(width), Fixed));
+ return style.release();
+}
+
void DateTimeEditElement::didBlurFromField()
{
if (m_editControlOwner)
« no previous file with comments | « Source/WebCore/html/shadow/DateTimeEditElement.h ('k') | Source/WebCore/html/shadow/DateTimeFieldElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698