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

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: Addressed code review comments Created 6 years, 5 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 static void findCustomMessageTextDirection(const Element& anchor, const String& message, TextDirection& messageDir, String& subMessage, TextDirection& subMessag eDir)
410 {
411 bool hasStrongDirection;
412 subMessage = anchor.fastGetAttribute(titleAttr);
413 messageDir = determineDirectionality(message, hasStrongDirection);
414 if (!subMessage.isEmpty()) {
415 // Sub Msg takes direction of the element direction
tkent 2014/07/22 23:56:48 Msg -> message
Habib Virji 2014/07/23 13:32:03 Done.
416 subMessageDir = anchor.renderer()->style()->direction();
417 AtomicString dir = anchor.fastGetAttribute(dirAttr);
tkent 2014/07/22 23:56:49 Line 417-419 has no effect. It is unnecessary.
Habib Virji 2014/07/23 13:32:03 Done. Removed but it did work correctly if <input
418 if (!dir.isEmpty() && equalIgnoringCase(dir, "auto"))
419 determineDirectionality(message, hasStrongDirection);
420 }
421 }
422
408 void HTMLFormControlElement::updateVisibleValidationMessage() 423 void HTMLFormControlElement::updateVisibleValidationMessage()
409 { 424 {
410 Page* page = document().page(); 425 Page* page = document().page();
411 if (!page) 426 if (!page)
412 return; 427 return;
413 String message; 428 String message;
414 if (renderer() && willValidate()) 429 if (renderer() && willValidate())
415 message = validationMessage().stripWhiteSpace(); 430 message = validationMessage().stripWhiteSpace();
416 431
417 m_hasValidationMessage = true; 432 m_hasValidationMessage = true;
418 ValidationMessageClient* client = &page->validationMessageClient(); 433 ValidationMessageClient* client = &page->validationMessageClient();
419 if (message.isEmpty()) 434 if (message.isEmpty()) {
420 client->hideValidationMessage(*this); 435 client->hideValidationMessage(*this);
421 else 436 } else {
422 client->showValidationMessage(*this, message); 437 TextDirection messageDir, subMessageDir = LTR;
tkent 2014/07/22 23:56:49 We don't declare multiple variables at once.
Habib Virji 2014/07/23 13:32:03 Done.
438 String subMessage = String();
439 findCustomMessageTextDirection(*this, message, messageDir, subMessage, s ubMessageDir);
440 client->showValidationMessage(*this, message, messageDir, subMessage, su bMessageDir);
441 }
423 } 442 }
424 443
425 void HTMLFormControlElement::hideVisibleValidationMessage() 444 void HTMLFormControlElement::hideVisibleValidationMessage()
426 { 445 {
427 if (!m_hasValidationMessage) 446 if (!m_hasValidationMessage)
428 return; 447 return;
429 448
430 if (ValidationMessageClient* client = validationMessageClient()) 449 if (ValidationMessageClient* client = validationMessageClient())
431 client->hideValidationMessage(*this); 450 client->hideValidationMessage(*this);
432 } 451 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 551
533 void HTMLFormControlElement::setFocus(bool flag) 552 void HTMLFormControlElement::setFocus(bool flag)
534 { 553 {
535 LabelableElement::setFocus(flag); 554 LabelableElement::setFocus(flag);
536 555
537 if (!flag && wasChangedSinceLastFormControlChangeEvent()) 556 if (!flag && wasChangedSinceLastFormControlChangeEvent())
538 dispatchFormControlChangeEvent(); 557 dispatchFormControlChangeEvent();
539 } 558 }
540 559
541 } // namespace Webcore 560 } // namespace Webcore
OLDNEW
« no previous file with comments | « no previous file | Source/core/page/ValidationMessageClient.h » ('j') | Source/web/ValidationMessageClientImpl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698