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

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

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return; 209 return;
210 210
211 m_isAutofilled = autofilled; 211 m_isAutofilled = autofilled;
212 pseudoStateChanged(CSSSelector::PseudoAutofill); 212 pseudoStateChanged(CSSSelector::PseudoAutofill);
213 } 213 }
214 214
215 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element) { 215 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element) {
216 if (!element->isAutofocusable()) 216 if (!element->isAutofocusable())
217 return false; 217 return false;
218 if (element->document().isSandboxed(SandboxAutomaticFeatures)) { 218 if (element->document().isSandboxed(SandboxAutomaticFeatures)) {
219 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. 219 // FIXME: This message should be moved off the console once a solution to
220 // https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
220 element->document().addConsoleMessage(ConsoleMessage::create( 221 element->document().addConsoleMessage(ConsoleMessage::create(
221 SecurityMessageSource, ErrorMessageLevel, 222 SecurityMessageSource, ErrorMessageLevel,
222 "Blocked autofocusing on a form control because the form's frame is " 223 "Blocked autofocusing on a form control because the form's frame is "
223 "sandboxed and the 'allow-scripts' permission is not set.")); 224 "sandboxed and the 'allow-scripts' permission is not set."));
224 return false; 225 return false;
225 } 226 }
226 227
227 return true; 228 return true;
228 } 229 }
229 230
230 void HTMLFormControlElement::attachLayoutTree(const AttachContext& context) { 231 void HTMLFormControlElement::attachLayoutTree(const AttachContext& context) {
231 HTMLElement::attachLayoutTree(context); 232 HTMLElement::attachLayoutTree(context);
232 233
233 if (!layoutObject()) 234 if (!layoutObject())
234 return; 235 return;
235 236
236 // The call to updateFromElement() needs to go after the call through 237 // The call to updateFromElement() needs to go after the call through
237 // to the base class's attachLayoutTree() because that can sometimes do a clos e 238 // to the base class's attachLayoutTree() because that can sometimes do a
238 // on the layoutObject. 239 // close on the layoutObject.
239 layoutObject()->updateFromElement(); 240 layoutObject()->updateFromElement();
240 241
241 // FIXME: Autofocus handling should be moved to insertedInto according to 242 // FIXME: Autofocus handling should be moved to insertedInto according to
242 // the standard. 243 // the standard.
243 if (shouldAutofocusOnAttach(this)) 244 if (shouldAutofocusOnAttach(this))
244 document().setAutofocusElement(this); 245 document().setAutofocusElement(this);
245 } 246 }
246 247
247 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) { 248 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) {
248 FormAssociatedElement::didMoveToNewDocument(oldDocument); 249 FormAssociatedElement::didMoveToNewDocument(oldDocument);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 bool HTMLFormControlElement::shouldHaveFocusAppearance() const { 376 bool HTMLFormControlElement::shouldHaveFocusAppearance() const {
376 return !m_wasFocusedByMouse || shouldShowFocusRingOnMouseFocus(); 377 return !m_wasFocusedByMouse || shouldShowFocusRingOnMouseFocus();
377 } 378 }
378 379
379 void HTMLFormControlElement::dispatchFocusEvent( 380 void HTMLFormControlElement::dispatchFocusEvent(
380 Element* oldFocusedElement, 381 Element* oldFocusedElement,
381 WebFocusType type, 382 WebFocusType type,
382 InputDeviceCapabilities* sourceCapabilities) { 383 InputDeviceCapabilities* sourceCapabilities) {
383 if (type != WebFocusTypePage) 384 if (type != WebFocusTypePage)
384 m_wasFocusedByMouse = type == WebFocusTypeMouse; 385 m_wasFocusedByMouse = type == WebFocusTypeMouse;
385 // ContainerNode::handleStyleChangeOnFocusStateChange() will inform LayoutThem e about the focus state change. 386 // ContainerNode::handleStyleChangeOnFocusStateChange() will inform
387 // LayoutTheme about the focus state change.
386 HTMLElement::dispatchFocusEvent(oldFocusedElement, type, sourceCapabilities); 388 HTMLElement::dispatchFocusEvent(oldFocusedElement, type, sourceCapabilities);
387 } 389 }
388 390
389 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) { 391 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) {
390 if (!m_wasFocusedByMouse) 392 if (!m_wasFocusedByMouse)
391 return; 393 return;
392 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) 394 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown)
393 return; 395 return;
394 396
395 bool oldShouldHaveFocusAppearance = shouldHaveFocusAppearance(); 397 bool oldShouldHaveFocusAppearance = shouldHaveFocusAppearance();
396 m_wasFocusedByMouse = false; 398 m_wasFocusedByMouse = false;
397 399
398 // Change of m_wasFocusByMouse may affect shouldHaveFocusAppearance() and Layo utTheme::isFocused(). 400 // Change of m_wasFocusByMouse may affect shouldHaveFocusAppearance() and
399 // Inform LayoutTheme if shouldHaveFocusAppearance() changes. 401 // LayoutTheme::isFocused(). Inform LayoutTheme if
402 // shouldHaveFocusAppearance() changes.
400 if (oldShouldHaveFocusAppearance != shouldHaveFocusAppearance() && 403 if (oldShouldHaveFocusAppearance != shouldHaveFocusAppearance() &&
401 layoutObject()) 404 layoutObject())
402 LayoutTheme::theme().controlStateChanged(*layoutObject(), 405 LayoutTheme::theme().controlStateChanged(*layoutObject(),
403 FocusControlState); 406 FocusControlState);
404 } 407 }
405 408
406 short HTMLFormControlElement::tabIndex() const { 409 short HTMLFormControlElement::tabIndex() const {
407 // Skip the supportsFocus check in HTMLElement. 410 // Skip the supportsFocus check in HTMLElement.
408 return Element::tabIndex(); 411 return Element::tabIndex();
409 } 412 }
(...skipping 15 matching lines...) Expand all
425 } else { 428 } else {
426 // If the following assertion fails, setNeedsWillValidateCheck() is not 429 // If the following assertion fails, setNeedsWillValidateCheck() is not
427 // called correctly when something which changes recalcWillValidate() result 430 // called correctly when something which changes recalcWillValidate() result
428 // is updated. 431 // is updated.
429 DCHECK_EQ(m_willValidate, recalcWillValidate()); 432 DCHECK_EQ(m_willValidate, recalcWillValidate());
430 } 433 }
431 return m_willValidate; 434 return m_willValidate;
432 } 435 }
433 436
434 void HTMLFormControlElement::setNeedsWillValidateCheck() { 437 void HTMLFormControlElement::setNeedsWillValidateCheck() {
435 // We need to recalculate willValidate immediately because willValidate change can causes style change. 438 // We need to recalculate willValidate immediately because willValidate change
439 // can causes style change.
436 bool newWillValidate = recalcWillValidate(); 440 bool newWillValidate = recalcWillValidate();
437 if (m_willValidateInitialized && m_willValidate == newWillValidate) 441 if (m_willValidateInitialized && m_willValidate == newWillValidate)
438 return; 442 return;
439 m_willValidateInitialized = true; 443 m_willValidateInitialized = true;
440 m_willValidate = newWillValidate; 444 m_willValidate = newWillValidate;
441 // Needs to force setNeedsValidityCheck() to invalidate validity state of 445 // Needs to force setNeedsValidityCheck() to invalidate validity state of
442 // FORM/FIELDSET. If this element updates willValidate twice and 446 // FORM/FIELDSET. If this element updates willValidate twice and
443 // isValidElement() is not called between them, the second call of this 447 // isValidElement() is not called between them, the second call of this
444 // function still has m_validityIsDirty==true, which means 448 // function still has m_validityIsDirty==true, which means
445 // setNeedsValidityCheck() doesn't invalidate validity state of 449 // setNeedsValidityCheck() doesn't invalidate validity state of
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 dispatchFormControlChangeEvent(); 644 dispatchFormControlChangeEvent();
641 } 645 }
642 646
643 void HTMLFormControlElement::copyNonAttributePropertiesFromElement( 647 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(
644 const Element& source) { 648 const Element& source) {
645 HTMLElement::copyNonAttributePropertiesFromElement(source); 649 HTMLElement::copyNonAttributePropertiesFromElement(source);
646 setNeedsValidityCheck(); 650 setNeedsValidityCheck();
647 } 651 }
648 652
649 } // namespace blink 653 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698