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

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

Issue 12159003: Merge 141195 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 11 months 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') | no next file » | 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 141524)
+++ Source/WebCore/html/shadow/DateTimeEditElement.cpp (working copy)
@@ -303,7 +303,7 @@
element->appendChild(Text::create(m_editElement.document(), String(&rightToLeftMark, 1)));
}
element->appendChild(Text::create(m_editElement.document(), text));
- m_editElement.appendChild(element);
+ m_editElement.fieldsWrapperElement()->appendChild(element);
}
DateTimeNumericFieldElement::Parameters DateTimeEditBuilder::createNumericFieldParameters(const Decimal& msPerFieldUnit, const Decimal& msPerFieldSize) const
@@ -346,12 +346,18 @@
m_fields[fieldIndex]->removeEventHandler();
}
+inline Element* DateTimeEditElement::fieldsWrapperElement() const
+{
+ ASSERT(firstChild());
+ return toElement(firstChild());
+}
+
void DateTimeEditElement::addField(PassRefPtr<DateTimeFieldElement> field)
{
if (m_fields.size() == m_fields.capacity())
return;
m_fields.append(field.get());
- appendChild(field);
+ fieldsWrapperElement()->appendChild(field);
}
bool DateTimeEditElement::anyEditableFieldsHaveValues() const
@@ -382,7 +388,7 @@
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()) {
+ for (Node* child = fieldsWrapperElement()->firstChild(); child; child = child->nextSibling()) {
if (!child->isElementNode())
continue;
Element* childElement = toElement(child);
@@ -396,7 +402,7 @@
width += style->font().width(childElement->textContent());
}
}
- style->setMinWidth(Length(ceilf(width), Fixed));
+ style->setWidth(Length(ceilf(width), Fixed));
return style.release();
}
@@ -514,14 +520,22 @@
void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const DateComponents& dateValue)
{
+ DEFINE_STATIC_LOCAL(AtomicString, fieldsWrapperPseudoId, ("-webkit-datetime-edit-fields-wrapper", AtomicString::ConstructFromLiteral));
+ if (!firstChild()) {
+ RefPtr<HTMLDivElement> element = HTMLDivElement::create(document());
+ element->setPseudo(fieldsWrapperPseudoId);
+ appendChild(element.get());
+ }
+ Element* fieldsWrapper = fieldsWrapperElement();
+
size_t focusedFieldIndex = this->focusedFieldIndex();
DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex);
const AtomicString focusedFieldId = focusedField ? focusedField->shadowPseudoId() : nullAtom;
DateTimeEditBuilder builder(*this, layoutParameters, dateValue);
- Node* lastChildToBeRemoved = lastChild();
+ Node* lastChildToBeRemoved = fieldsWrapper->lastChild();
if (!builder.build(layoutParameters.dateTimeFormat) || m_fields.isEmpty()) {
- lastChildToBeRemoved = lastChild();
+ lastChildToBeRemoved = fieldsWrapper->lastChild();
builder.build(layoutParameters.fallbackDateTimeFormat);
}
@@ -537,11 +551,12 @@
}
if (lastChildToBeRemoved) {
- for (Node* childNode = firstChild(); childNode; childNode = firstChild()) {
- removeChild(childNode);
+ for (Node* childNode = fieldsWrapper->firstChild(); childNode; childNode = fieldsWrapper->firstChild()) {
+ fieldsWrapper->removeChild(childNode);
if (childNode == lastChildToBeRemoved)
break;
}
+ setNeedsStyleRecalc();
}
}
« no previous file with comments | « Source/WebCore/html/shadow/DateTimeEditElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698