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

Side by Side Diff: Source/core/testing/Internals.cpp

Issue 120443003: Add autofill preview support for Textarea (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test code for textarea setSuggestedValue() Created 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 void Internals::resetToConsistentState(Page* page) 190 void Internals::resetToConsistentState(Page* page)
191 { 191 {
192 ASSERT(page); 192 ASSERT(page);
193 193
194 page->setDeviceScaleFactor(1); 194 page->setDeviceScaleFactor(1);
195 page->setIsCursorVisible(true); 195 page->setIsCursorVisible(true);
196 page->setPageScaleFactor(1, IntPoint(0, 0)); 196 page->setPageScaleFactor(1, IntPoint(0, 0));
197 page->setPagination(Pagination()); 197 page->setPagination(Pagination());
198 TextRun::setAllowsRoundingHacks(false); 198 TextRun::setAllowsRoundingHacks(false);
199 WebCore::overrideUserPreferredLanguages(Vector<String>()); 199 WebCore::overrideUserPreferredLanguages(Vector<AtomicString>());
200 delete s_pagePopupDriver; 200 delete s_pagePopupDriver;
201 s_pagePopupDriver = 0; 201 s_pagePopupDriver = 0;
202 page->chrome().client().resetPagePopupDriver(); 202 page->chrome().client().resetPagePopupDriver();
203 if (!page->mainFrame()->spellChecker().isContinuousSpellCheckingEnabled()) 203 if (!page->mainFrame()->spellChecker().isContinuousSpellCheckingEnabled())
204 page->mainFrame()->spellChecker().toggleContinuousSpellChecking(); 204 page->mainFrame()->spellChecker().toggleContinuousSpellChecking();
205 if (page->mainFrame()->editor().isOverwriteModeEnabled()) 205 if (page->mainFrame()->editor().isOverwriteModeEnabled())
206 page->mainFrame()->editor().toggleOverwriteModeEnabled(); 206 page->mainFrame()->editor().toggleOverwriteModeEnabled();
207 207
208 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator( )) 208 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator( ))
209 scrollingCoordinator->reset(); 209 scrollingCoordinator->reset();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 Node* Internals::parentTreeScope(Node* node, ExceptionState& exceptionState) 373 Node* Internals::parentTreeScope(Node* node, ExceptionState& exceptionState)
374 { 374 {
375 if (!node) { 375 if (!node) {
376 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 376 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
377 return 0; 377 return 0;
378 } 378 }
379 const TreeScope* parentTreeScope = node->treeScope().parentTreeScope(); 379 const TreeScope* parentTreeScope = node->treeScope().parentTreeScope();
380 return parentTreeScope ? parentTreeScope->rootNode() : 0; 380 return parentTreeScope ? parentTreeScope->rootNode() : 0;
381 } 381 }
382 382
383 bool Internals::hasSelectorForIdInShadow(Element* host, const String& idValue, E xceptionState& exceptionState) 383 bool Internals::hasSelectorForIdInShadow(Element* host, const AtomicString& idVa lue, ExceptionState& exceptionState)
384 { 384 {
385 if (!host || !host->shadow()) { 385 if (!host || !host->shadow()) {
386 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 386 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
387 return 0; 387 return 0;
388 } 388 }
389 389
390 return host->shadow()->ensureSelectFeatureSet().hasSelectorForId(idValue); 390 return host->shadow()->ensureSelectFeatureSet().hasSelectorForId(idValue);
391 } 391 }
392 392
393 bool Internals::hasSelectorForClassInShadow(Element* host, const String& classNa me, ExceptionState& exceptionState) 393 bool Internals::hasSelectorForClassInShadow(Element* host, const AtomicString& c lassName, ExceptionState& exceptionState)
394 { 394 {
395 if (!host || !host->shadow()) { 395 if (!host || !host->shadow()) {
396 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 396 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
397 return 0; 397 return 0;
398 } 398 }
399 399
400 return host->shadow()->ensureSelectFeatureSet().hasSelectorForClass(classNam e); 400 return host->shadow()->ensureSelectFeatureSet().hasSelectorForClass(classNam e);
401 } 401 }
402 402
403 bool Internals::hasSelectorForAttributeInShadow(Element* host, const String& att ributeName, ExceptionState& exceptionState) 403 bool Internals::hasSelectorForAttributeInShadow(Element* host, const AtomicStrin g& attributeName, ExceptionState& exceptionState)
404 { 404 {
405 if (!host || !host->shadow()) { 405 if (!host || !host->shadow()) {
406 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 406 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
407 return 0; 407 return 0;
408 } 408 }
409 409
410 return host->shadow()->ensureSelectFeatureSet().hasSelectorForAttribute(attr ibuteName); 410 return host->shadow()->ensureSelectFeatureSet().hasSelectorForAttribute(attr ibuteName);
411 } 411 }
412 412
413 bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& p seudoClass, ExceptionState& exceptionState) 413 bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& p seudoClass, ExceptionState& exceptionState)
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 case ShadowRoot::UserAgentShadowRoot: 671 case ShadowRoot::UserAgentShadowRoot:
672 return String("UserAgentShadowRoot"); 672 return String("UserAgentShadowRoot");
673 case ShadowRoot::AuthorShadowRoot: 673 case ShadowRoot::AuthorShadowRoot:
674 return String("AuthorShadowRoot"); 674 return String("AuthorShadowRoot");
675 default: 675 default:
676 ASSERT_NOT_REACHED(); 676 ASSERT_NOT_REACHED();
677 return String("Unknown"); 677 return String("Unknown");
678 } 678 }
679 } 679 }
680 680
681 String Internals::shadowPseudoId(Element* element, ExceptionState& exceptionStat e) 681 const AtomicString& Internals::shadowPseudoId(Element* element, ExceptionState& exceptionState)
682 { 682 {
683 if (!element) { 683 if (!element) {
684 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 684 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
685 return String(); 685 return nullAtom;
686 } 686 }
687 687
688 return element->shadowPseudoId().string(); 688 return element->shadowPseudoId();
689 } 689 }
690 690
691 void Internals::setShadowPseudoId(Element* element, const String& id, ExceptionS tate& exceptionState) 691 void Internals::setShadowPseudoId(Element* element, const AtomicString& id, Exce ptionState& exceptionState)
692 { 692 {
693 if (!element) { 693 if (!element) {
694 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 694 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
695 return; 695 return;
696 } 696 }
697 697
698 return element->setShadowPseudoId(id); 698 return element->setShadowPseudoId(id);
699 } 699 }
700 700
701 String Internals::visiblePlaceholder(Element* element) 701 String Internals::visiblePlaceholder(Element* element)
702 { 702 {
703 if (element && isHTMLTextFormControlElement(*element)) { 703 if (element && isHTMLTextFormControlElement(*element)) {
704 if (toHTMLTextFormControlElement(element)->placeholderShouldBeVisible()) 704 if (toHTMLTextFormControlElement(element)->placeholderShouldBeVisible())
705 return toHTMLTextFormControlElement(element)->placeholderElement()-> textContent(); 705 return toHTMLTextFormControlElement(element)->placeholderElement()-> textContent();
706 } 706 }
707 707
708 return String(); 708 return String();
709 } 709 }
710 710
711 void Internals::selectColorInColorChooser(Element* element, const String& colorV alue) 711 void Internals::selectColorInColorChooser(Element* element, const String& colorV alue)
712 { 712 {
713 if (!element->hasTagName(inputTag)) 713 if (!element->hasTagName(inputTag))
714 return; 714 return;
715 toHTMLInputElement(element)->selectColorInColorChooser(Color(colorValue)); 715 Color color;
716 if (!color.setFromString(colorValue))
717 return;
718 toHTMLInputElement(element)->selectColorInColorChooser(color);
716 } 719 }
717 720
718 Vector<String> Internals::formControlStateOfHistoryItem(ExceptionState& exceptio nState) 721 Vector<String> Internals::formControlStateOfHistoryItem(ExceptionState& exceptio nState)
719 { 722 {
720 HistoryItem* mainItem = frame()->loader().currentItem(); 723 HistoryItem* mainItem = frame()->loader().currentItem();
721 if (!mainItem) { 724 if (!mainItem) {
722 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 725 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
723 return Vector<String>(); 726 return Vector<String>();
724 } 727 }
725 return mainItem->documentState(); 728 return mainItem->documentState();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 return false; 1012 return false;
1010 } 1013 }
1011 1014
1012 String Internals::suggestedValue(Element* element, ExceptionState& exceptionStat e) 1015 String Internals::suggestedValue(Element* element, ExceptionState& exceptionStat e)
1013 { 1016 {
1014 if (!element) { 1017 if (!element) {
1015 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 1018 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
1016 return String(); 1019 return String();
1017 } 1020 }
1018 1021
1019 if (!element->hasTagName(inputTag)) { 1022 if (!element->isFormControlElement()) {
1020 exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeE rror); 1023 exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeE rror);
1021 return String(); 1024 return String();
1022 } 1025 }
1023 1026
1024 return toHTMLInputElement(element)->suggestedValue(); 1027 String suggestedValue;
1028 if (element->hasTagName(inputTag))
1029 suggestedValue = toHTMLInputElement(element)->suggestedValue();
1030
1031 // FIXME: We should be using hasTagName instead but Windows port doesn't lin k QualifiedNames properly.
tkent 2014/01/06 23:29:49 What do you mean? Why don't you use hasTagName(te
ziran.sun 2014/01/07 17:18:26 I noticed this comment in Internals::wasLastChange
tkent 2014/01/08 00:59:38 I don't think we have such problem now. Probably
ziran.sun 2014/01/08 10:45:54 Done.
1032 if (element->tagName() == "TEXTAREA")
1033 suggestedValue = toHTMLTextAreaElement(element)->suggestedValue();
1034 return suggestedValue;
1025 } 1035 }
1026 1036
1027 void Internals::setSuggestedValue(Element* element, const String& value, Excepti onState& exceptionState) 1037 void Internals::setSuggestedValue(Element* element, const String& value, Excepti onState& exceptionState)
1028 { 1038 {
1029 if (!element) { 1039 if (!element) {
1030 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 1040 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
1031 return; 1041 return;
1032 } 1042 }
1033 1043
1034 if (!element->hasTagName(inputTag)) { 1044 if (!element->isFormControlElement()) {
1035 exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeE rror); 1045 exceptionState.throwUninformativeAndGenericDOMException(InvalidNodeTypeE rror);
1036 return; 1046 return;
1037 } 1047 }
1038 1048
1039 toHTMLInputElement(element)->setSuggestedValue(value); 1049 if (element->hasTagName(inputTag))
1050 toHTMLInputElement(element)->setSuggestedValue(value);
1051
1052 // FIXME: We should be using hasTagName instead but Windows port doesn't lin k QualifiedNames properly.
1053 if (element->tagName() == "TEXTAREA")
1054 toHTMLTextAreaElement(element)->setSuggestedValue(value);
1040 } 1055 }
1041 1056
1042 void Internals::setEditingValue(Element* element, const String& value, Exception State& exceptionState) 1057 void Internals::setEditingValue(Element* element, const String& value, Exception State& exceptionState)
1043 { 1058 {
1044 if (!element) { 1059 if (!element) {
1045 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 1060 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
1046 return; 1061 return;
1047 } 1062 }
1048 1063
1049 if (!element->hasTagName(inputTag)) { 1064 if (!element->hasTagName(inputTag)) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 SpellCheckRequester* requester = spellCheckRequester(document); 1267 SpellCheckRequester* requester = spellCheckRequester(document);
1253 1268
1254 if (!requester) { 1269 if (!requester) {
1255 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 1270 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
1256 return -1; 1271 return -1;
1257 } 1272 }
1258 1273
1259 return requester->lastProcessedSequence(); 1274 return requester->lastProcessedSequence();
1260 } 1275 }
1261 1276
1262 Vector<String> Internals::userPreferredLanguages() const 1277 Vector<AtomicString> Internals::userPreferredLanguages() const
1263 { 1278 {
1264 return WebCore::userPreferredLanguages(); 1279 return WebCore::userPreferredLanguages();
1265 } 1280 }
1266 1281
1282 // Optimally, the bindings generator would pass a Vector<AtomicString> here but
1283 // this is not supported yet.
1267 void Internals::setUserPreferredLanguages(const Vector<String>& languages) 1284 void Internals::setUserPreferredLanguages(const Vector<String>& languages)
1268 { 1285 {
1269 WebCore::overrideUserPreferredLanguages(languages); 1286 Vector<AtomicString> atomicLanguages;
1287 for (size_t i = 0; i < languages.size(); ++i)
1288 atomicLanguages.append(AtomicString(languages[i]));
1289 WebCore::overrideUserPreferredLanguages(atomicLanguages);
1270 } 1290 }
1271 1291
1272 unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& e xceptionState) 1292 unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& e xceptionState)
1273 { 1293 {
1274 if (!document) { 1294 if (!document) {
1275 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); 1295 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or);
1276 return 0; 1296 return 0;
1277 } 1297 }
1278 1298
1279 return WheelController::from(document)->wheelEventHandlerCount(); 1299 return WheelController::from(document)->wheelEventHandlerCount();
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 if (view->compositor()) 2340 if (view->compositor())
2321 view->compositor()->updateCompositingLayers(CompositingUpdateFinishAllDe ferredWork); 2341 view->compositor()->updateCompositingLayers(CompositingUpdateFinishAllDe ferredWork);
2322 } 2342 }
2323 2343
2324 void Internals::setZoomFactor(float factor) 2344 void Internals::setZoomFactor(float factor)
2325 { 2345 {
2326 frame()->setPageZoomFactor(factor); 2346 frame()->setPageZoomFactor(factor);
2327 } 2347 }
2328 2348
2329 } 2349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698