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

Side by Side Diff: Source/core/html/HTMLFormControlElement.cpp

Issue 389343002: Custom validation message to take into account text direction (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to latest master changes Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 19 matching lines...) Expand all
30 #include "core/html/HTMLFieldSetElement.h" 30 #include "core/html/HTMLFieldSetElement.h"
31 #include "core/html/HTMLFormElement.h" 31 #include "core/html/HTMLFormElement.h"
32 #include "core/html/HTMLInputElement.h" 32 #include "core/html/HTMLInputElement.h"
33 #include "core/html/HTMLLegendElement.h" 33 #include "core/html/HTMLLegendElement.h"
34 #include "core/html/ValidityState.h" 34 #include "core/html/ValidityState.h"
35 #include "core/frame/UseCounter.h" 35 #include "core/frame/UseCounter.h"
36 #include "core/page/Page.h" 36 #include "core/page/Page.h"
37 #include "core/page/ValidationMessageClient.h" 37 #include "core/page/ValidationMessageClient.h"
38 #include "core/rendering/RenderBox.h" 38 #include "core/rendering/RenderBox.h"
39 #include "core/rendering/RenderTheme.h" 39 #include "core/rendering/RenderTheme.h"
40 #include "platform/text/BidiTextRun.h"
40 #include "wtf/Vector.h" 41 #include "wtf/Vector.h"
41 42
42 namespace blink { 43 namespace blink {
43 44
44 using namespace HTMLNames; 45 using namespace HTMLNames;
45 46
46 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument& document, HTMLFormElement* form) 47 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument& document, HTMLFormElement* form)
47 : LabelableElement(tagName, document) 48 : LabelableElement(tagName, document)
48 , m_disabled(false) 49 , m_disabled(false)
49 , m_isAutofilled(false) 50 , m_isAutofilled(false)
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (m_willValidateInitialized && m_willValidate == newWillValidate) 399 if (m_willValidateInitialized && m_willValidate == newWillValidate)
399 return; 400 return;
400 m_willValidateInitialized = true; 401 m_willValidateInitialized = true;
401 m_willValidate = newWillValidate; 402 m_willValidate = newWillValidate;
402 setNeedsValidityCheck(); 403 setNeedsValidityCheck();
403 setNeedsStyleRecalc(SubtreeStyleChange); 404 setNeedsStyleRecalc(SubtreeStyleChange);
404 if (!m_willValidate) 405 if (!m_willValidate)
405 hideVisibleValidationMessage(); 406 hideVisibleValidationMessage();
406 } 407 }
407 408
409 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe ssageDir)
410 {
411 bool hasStrongDirection;
412 subMessage = fastGetAttribute(titleAttr);
413 messageDir = determineDirectionality(message, hasStrongDirection);
414 if (!subMessage.isEmpty())
415 subMessageDir = renderer()->style()->direction();
416 AtomicString dir = fastGetAttribute(dirAttr);
tkent 2014/08/08 01:41:14 Why do you refer to |dir| attribute though we alre
417 if (!dir.isEmpty())
418 subMessageDir = equalIgnoringCase(dir, "auto") ? determineDirectionality (message, hasStrongDirection): equalIgnoringCase(dir, "ltr") ? LTR: RTL;
419 }
420
408 void HTMLFormControlElement::updateVisibleValidationMessage() 421 void HTMLFormControlElement::updateVisibleValidationMessage()
409 { 422 {
410 Page* page = document().page(); 423 Page* page = document().page();
411 if (!page) 424 if (!page)
412 return; 425 return;
413 String message; 426 String message;
414 if (renderer() && willValidate()) 427 if (renderer() && willValidate())
415 message = validationMessage().stripWhiteSpace(); 428 message = validationMessage().stripWhiteSpace();
416 429
417 m_hasValidationMessage = true; 430 m_hasValidationMessage = true;
418 ValidationMessageClient* client = &page->validationMessageClient(); 431 ValidationMessageClient* client = &page->validationMessageClient();
432 TextDirection messageDir = LTR;
433 TextDirection subMessageDir = LTR;
434 String subMessage = String();
419 if (message.isEmpty()) 435 if (message.isEmpty())
420 client->hideValidationMessage(*this); 436 client->hideValidationMessage(*this);
421 else 437 else
422 client->showValidationMessage(*this, message); 438 findCustomValidationMessageTextDirection(message, messageDir, subMessage , subMessageDir);
439 client->showValidationMessage(*this, message, messageDir, subMessage, subMes sageDir);
423 } 440 }
424 441
425 void HTMLFormControlElement::hideVisibleValidationMessage() 442 void HTMLFormControlElement::hideVisibleValidationMessage()
426 { 443 {
427 if (!m_hasValidationMessage) 444 if (!m_hasValidationMessage)
428 return; 445 return;
429 446
430 if (ValidationMessageClient* client = validationMessageClient()) 447 if (ValidationMessageClient* client = validationMessageClient())
431 client->hideValidationMessage(*this); 448 client->hideValidationMessage(*this);
432 } 449 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 549
533 void HTMLFormControlElement::setFocus(bool flag) 550 void HTMLFormControlElement::setFocus(bool flag)
534 { 551 {
535 LabelableElement::setFocus(flag); 552 LabelableElement::setFocus(flag);
536 553
537 if (!flag && wasChangedSinceLastFormControlChangeEvent()) 554 if (!flag && wasChangedSinceLastFormControlChangeEvent())
538 dispatchFormControlChangeEvent(); 555 dispatchFormControlChangeEvent();
539 } 556 }
540 557
541 } // namespace Webcore 558 } // namespace Webcore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFormControlElement.h ('k') | Source/core/html/HTMLFormControlElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698