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

Unified Diff: Source/WebCore/html/shadow/DateTimeNumericFieldElement.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
Index: Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
===================================================================
--- Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp (revision 137540)
+++ Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp (working copy)
@@ -27,14 +27,13 @@
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
#include "DateTimeNumericFieldElement.h"
-#include "FontCache.h"
+#include "Font.h"
#include "KeyboardEvent.h"
#include "PlatformLocale.h"
-#include "RenderStyle.h"
-#include "StyleResolver.h"
-#include "TextRun.h"
#include <wtf/text/StringBuilder.h>
+using namespace WTF::Unicode;
+
namespace WebCore {
static const DOMTimeStamp typeAheadTimeout = 1000;
@@ -66,7 +65,19 @@
, m_value(0)
, m_hasValue(false)
{
- setHasCustomCallbacks();
+ // We show a direction-neutral string such as "--" as a placeholder. It
+ // should follow the direction of numeric values.
+ if (localeForOwner().isRTL()) {
+ Direction dir = direction(formatValue(this->maximum())[0]);
+ if (dir == LeftToRight || dir == EuropeanNumber || dir == ArabicNumber) {
+ StringBuilder builder;
+ builder.reserveCapacity(m_placeholder.length() + 2);
+ builder.append(leftToRightMark);
+ builder.append(m_placeholder);
+ builder.append(rightToLeftMark);
+ m_placeholder = builder.toString();
+ }
+ }
}
int DateTimeNumericFieldElement::clampValueForHardLimits(int value) const
@@ -74,16 +85,12 @@
return clampValue(value);
}
-PassRefPtr<RenderStyle> DateTimeNumericFieldElement::customStyleForRenderer()
+float DateTimeNumericFieldElement::maximumWidth(const Font& font)
{
- FontCachePurgePreventer fontCachePurgePreventer;
- RefPtr<RenderStyle> originalStyle = document()->styleResolver()->styleForElement(this);
- RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
- float maxiumWidth = style->font().width(m_placeholder);
- maxiumWidth = std::max(maxiumWidth, style->font().width(formatValue(maximum())));
- maxiumWidth = std::max(maxiumWidth, style->font().width(value()));
- style->setMinWidth(Length(maxiumWidth, Fixed));
- return style.release();
+ float maximumWidth = font.width(m_placeholder);
+ maximumWidth = std::max(maximumWidth, font.width(formatValue(maximum())));
+ maximumWidth = std::max(maximumWidth, font.width(value()));
+ return maximumWidth + DateTimeFieldElement::maximumWidth(font);
}
int DateTimeNumericFieldElement::defaultValueForStepDown() const
« no previous file with comments | « Source/WebCore/html/shadow/DateTimeNumericFieldElement.h ('k') | Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698