OLD | NEW |
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 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved. |
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
6 * (http://www.torchmobile.com/) | 6 * (http://www.torchmobile.com/) |
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 size_t first_separator = html_language.Find('-'); | 198 size_t first_separator = html_language.Find('-'); |
199 if (first_separator != kNotFound) | 199 if (first_separator != kNotFound) |
200 html_language = html_language.Left(first_separator); | 200 html_language = html_language.Left(first_separator); |
201 String ui_language = DefaultLanguage(); | 201 String ui_language = DefaultLanguage(); |
202 first_separator = ui_language.Find('-'); | 202 first_separator = ui_language.Find('-'); |
203 if (first_separator != kNotFound) | 203 if (first_separator != kNotFound) |
204 ui_language = ui_language.Left(first_separator); | 204 ui_language = ui_language.Left(first_separator); |
205 first_separator = ui_language.Find('_'); | 205 first_separator = ui_language.Find('_'); |
206 if (first_separator != kNotFound) | 206 if (first_separator != kNotFound) |
207 ui_language = ui_language.Left(first_separator); | 207 ui_language = ui_language.Left(first_separator); |
208 if (!EqualIgnoringCase(html_language, ui_language)) | 208 if (!DeprecatedEqualIgnoringCase(html_language, ui_language)) |
209 UseCounter::Count(GetDocument(), | 209 UseCounter::Count(GetDocument(), |
210 UseCounter::kLangAttributeDoesNotMatchToUILocale); | 210 UseCounter::kLangAttributeDoesNotMatchToUILocale); |
211 } else { | 211 } else { |
212 // The empty string means the language is explicitly unknown. | 212 // The empty string means the language is explicitly unknown. |
213 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, | 213 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, |
214 CSSValueAuto); | 214 CSSValueAuto); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 bool HTMLElement::IsPresentationAttribute(const QualifiedName& name) const { | 218 bool HTMLElement::IsPresentationAttribute(const QualifiedName& name) const { |
219 if (name == alignAttr || name == contenteditableAttr || name == hiddenAttr || | 219 if (name == alignAttr || name == contenteditableAttr || name == hiddenAttr || |
220 name == langAttr || name.Matches(XMLNames::langAttr) || | 220 name == langAttr || name.Matches(XMLNames::langAttr) || |
221 name == draggableAttr || name == dirAttr) | 221 name == draggableAttr || name == dirAttr) |
222 return true; | 222 return true; |
223 return Element::IsPresentationAttribute(name); | 223 return Element::IsPresentationAttribute(name); |
224 } | 224 } |
225 | 225 |
226 static inline bool IsValidDirAttribute(const AtomicString& value) { | 226 static inline bool IsValidDirAttribute(const AtomicString& value) { |
227 return EqualIgnoringCase(value, "auto") || EqualIgnoringCase(value, "ltr") || | 227 return DeprecatedEqualIgnoringCase(value, "auto") || |
228 EqualIgnoringCase(value, "rtl"); | 228 DeprecatedEqualIgnoringCase(value, "ltr") || |
| 229 DeprecatedEqualIgnoringCase(value, "rtl"); |
229 } | 230 } |
230 | 231 |
231 void HTMLElement::CollectStyleForPresentationAttribute( | 232 void HTMLElement::CollectStyleForPresentationAttribute( |
232 const QualifiedName& name, | 233 const QualifiedName& name, |
233 const AtomicString& value, | 234 const AtomicString& value, |
234 MutableStylePropertySet* style) { | 235 MutableStylePropertySet* style) { |
235 if (name == alignAttr) { | 236 if (name == alignAttr) { |
236 if (EqualIgnoringCase(value, "middle")) | 237 if (DeprecatedEqualIgnoringCase(value, "middle")) |
237 AddPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, | 238 AddPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, |
238 CSSValueCenter); | 239 CSSValueCenter); |
239 else | 240 else |
240 AddPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, | 241 AddPropertyToPresentationAttributeStyle(style, CSSPropertyTextAlign, |
241 value); | 242 value); |
242 } else if (name == contenteditableAttr) { | 243 } else if (name == contenteditableAttr) { |
243 if (value.IsEmpty() || EqualIgnoringCase(value, "true")) { | 244 if (value.IsEmpty() || DeprecatedEqualIgnoringCase(value, "true")) { |
244 AddPropertyToPresentationAttributeStyle( | 245 AddPropertyToPresentationAttributeStyle( |
245 style, CSSPropertyWebkitUserModify, CSSValueReadWrite); | 246 style, CSSPropertyWebkitUserModify, CSSValueReadWrite); |
246 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, | 247 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, |
247 CSSValueBreakWord); | 248 CSSValueBreakWord); |
248 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, | 249 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, |
249 CSSValueAfterWhiteSpace); | 250 CSSValueAfterWhiteSpace); |
250 UseCounter::Count(GetDocument(), UseCounter::kContentEditableTrue); | 251 UseCounter::Count(GetDocument(), UseCounter::kContentEditableTrue); |
251 if (HasTagName(htmlTag)) | 252 if (HasTagName(htmlTag)) |
252 UseCounter::Count(GetDocument(), | 253 UseCounter::Count(GetDocument(), |
253 UseCounter::kContentEditableTrueOnHTML); | 254 UseCounter::kContentEditableTrueOnHTML); |
254 } else if (EqualIgnoringCase(value, "plaintext-only")) { | 255 } else if (DeprecatedEqualIgnoringCase(value, "plaintext-only")) { |
255 AddPropertyToPresentationAttributeStyle( | 256 AddPropertyToPresentationAttributeStyle( |
256 style, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly); | 257 style, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly); |
257 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, | 258 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWordWrap, |
258 CSSValueBreakWord); | 259 CSSValueBreakWord); |
259 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, | 260 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLineBreak, |
260 CSSValueAfterWhiteSpace); | 261 CSSValueAfterWhiteSpace); |
261 UseCounter::Count(GetDocument(), | 262 UseCounter::Count(GetDocument(), |
262 UseCounter::kContentEditablePlainTextOnly); | 263 UseCounter::kContentEditablePlainTextOnly); |
263 } else if (EqualIgnoringCase(value, "false")) { | 264 } else if (DeprecatedEqualIgnoringCase(value, "false")) { |
264 AddPropertyToPresentationAttributeStyle( | 265 AddPropertyToPresentationAttributeStyle( |
265 style, CSSPropertyWebkitUserModify, CSSValueReadOnly); | 266 style, CSSPropertyWebkitUserModify, CSSValueReadOnly); |
266 } | 267 } |
267 } else if (name == hiddenAttr) { | 268 } else if (name == hiddenAttr) { |
268 AddPropertyToPresentationAttributeStyle(style, CSSPropertyDisplay, | 269 AddPropertyToPresentationAttributeStyle(style, CSSPropertyDisplay, |
269 CSSValueNone); | 270 CSSValueNone); |
270 } else if (name == draggableAttr) { | 271 } else if (name == draggableAttr) { |
271 UseCounter::Count(GetDocument(), UseCounter::kDraggableAttribute); | 272 UseCounter::Count(GetDocument(), UseCounter::kDraggableAttribute); |
272 if (EqualIgnoringCase(value, "true")) { | 273 if (DeprecatedEqualIgnoringCase(value, "true")) { |
273 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserDrag, | 274 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserDrag, |
274 CSSValueElement); | 275 CSSValueElement); |
275 AddPropertyToPresentationAttributeStyle(style, CSSPropertyUserSelect, | 276 AddPropertyToPresentationAttributeStyle(style, CSSPropertyUserSelect, |
276 CSSValueNone); | 277 CSSValueNone); |
277 } else if (EqualIgnoringCase(value, "false")) { | 278 } else if (DeprecatedEqualIgnoringCase(value, "false")) { |
278 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserDrag, | 279 AddPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUserDrag, |
279 CSSValueNone); | 280 CSSValueNone); |
280 } | 281 } |
281 } else if (name == dirAttr) { | 282 } else if (name == dirAttr) { |
282 if (EqualIgnoringCase(value, "auto")) { | 283 if (DeprecatedEqualIgnoringCase(value, "auto")) { |
283 AddPropertyToPresentationAttributeStyle( | 284 AddPropertyToPresentationAttributeStyle( |
284 style, CSSPropertyUnicodeBidi, UnicodeBidiAttributeForDirAuto(this)); | 285 style, CSSPropertyUnicodeBidi, UnicodeBidiAttributeForDirAuto(this)); |
285 } else { | 286 } else { |
286 if (IsValidDirAttribute(value)) | 287 if (IsValidDirAttribute(value)) |
287 AddPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, | 288 AddPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, |
288 value); | 289 value); |
289 else if (isHTMLBodyElement(*this)) | 290 else if (isHTMLBodyElement(*this)) |
290 AddPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, | 291 AddPropertyToPresentationAttributeStyle(style, CSSPropertyDirection, |
291 "ltr"); | 292 "ltr"); |
292 if (!HasTagName(bdiTag) && !HasTagName(bdoTag) && !HasTagName(outputTag)) | 293 if (!HasTagName(bdiTag) && !HasTagName(bdoTag) && !HasTagName(outputTag)) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 585 } |
585 | 586 |
586 void HTMLElement::ApplyAlignmentAttributeToStyle( | 587 void HTMLElement::ApplyAlignmentAttributeToStyle( |
587 const AtomicString& alignment, | 588 const AtomicString& alignment, |
588 MutableStylePropertySet* style) { | 589 MutableStylePropertySet* style) { |
589 // Vertical alignment with respect to the current baseline of the text | 590 // Vertical alignment with respect to the current baseline of the text |
590 // right or left means floating images. | 591 // right or left means floating images. |
591 CSSValueID float_value = CSSValueInvalid; | 592 CSSValueID float_value = CSSValueInvalid; |
592 CSSValueID vertical_align_value = CSSValueInvalid; | 593 CSSValueID vertical_align_value = CSSValueInvalid; |
593 | 594 |
594 if (EqualIgnoringCase(alignment, "absmiddle")) { | 595 if (DeprecatedEqualIgnoringCase(alignment, "absmiddle")) { |
595 vertical_align_value = CSSValueMiddle; | 596 vertical_align_value = CSSValueMiddle; |
596 } else if (EqualIgnoringCase(alignment, "absbottom")) { | 597 } else if (DeprecatedEqualIgnoringCase(alignment, "absbottom")) { |
597 vertical_align_value = CSSValueBottom; | 598 vertical_align_value = CSSValueBottom; |
598 } else if (EqualIgnoringCase(alignment, "left")) { | 599 } else if (DeprecatedEqualIgnoringCase(alignment, "left")) { |
599 float_value = CSSValueLeft; | 600 float_value = CSSValueLeft; |
600 vertical_align_value = CSSValueTop; | 601 vertical_align_value = CSSValueTop; |
601 } else if (EqualIgnoringCase(alignment, "right")) { | 602 } else if (DeprecatedEqualIgnoringCase(alignment, "right")) { |
602 float_value = CSSValueRight; | 603 float_value = CSSValueRight; |
603 vertical_align_value = CSSValueTop; | 604 vertical_align_value = CSSValueTop; |
604 } else if (EqualIgnoringCase(alignment, "top")) { | 605 } else if (DeprecatedEqualIgnoringCase(alignment, "top")) { |
605 vertical_align_value = CSSValueTop; | 606 vertical_align_value = CSSValueTop; |
606 } else if (EqualIgnoringCase(alignment, "middle")) { | 607 } else if (DeprecatedEqualIgnoringCase(alignment, "middle")) { |
607 vertical_align_value = CSSValueWebkitBaselineMiddle; | 608 vertical_align_value = CSSValueWebkitBaselineMiddle; |
608 } else if (EqualIgnoringCase(alignment, "center")) { | 609 } else if (DeprecatedEqualIgnoringCase(alignment, "center")) { |
609 vertical_align_value = CSSValueMiddle; | 610 vertical_align_value = CSSValueMiddle; |
610 } else if (EqualIgnoringCase(alignment, "bottom")) { | 611 } else if (DeprecatedEqualIgnoringCase(alignment, "bottom")) { |
611 vertical_align_value = CSSValueBaseline; | 612 vertical_align_value = CSSValueBaseline; |
612 } else if (EqualIgnoringCase(alignment, "texttop")) { | 613 } else if (DeprecatedEqualIgnoringCase(alignment, "texttop")) { |
613 vertical_align_value = CSSValueTextTop; | 614 vertical_align_value = CSSValueTextTop; |
614 } | 615 } |
615 | 616 |
616 if (float_value != CSSValueInvalid) | 617 if (float_value != CSSValueInvalid) |
617 AddPropertyToPresentationAttributeStyle(style, CSSPropertyFloat, | 618 AddPropertyToPresentationAttributeStyle(style, CSSPropertyFloat, |
618 float_value); | 619 float_value); |
619 | 620 |
620 if (vertical_align_value != CSSValueInvalid) | 621 if (vertical_align_value != CSSValueInvalid) |
621 AddPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, | 622 AddPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, |
622 vertical_align_value); | 623 vertical_align_value); |
623 } | 624 } |
624 | 625 |
625 bool HTMLElement::HasCustomFocusLogic() const { | 626 bool HTMLElement::HasCustomFocusLogic() const { |
626 return false; | 627 return false; |
627 } | 628 } |
628 | 629 |
629 String HTMLElement::contentEditable() const { | 630 String HTMLElement::contentEditable() const { |
630 const AtomicString& value = FastGetAttribute(contenteditableAttr); | 631 const AtomicString& value = FastGetAttribute(contenteditableAttr); |
631 | 632 |
632 if (value.IsNull()) | 633 if (value.IsNull()) |
633 return "inherit"; | 634 return "inherit"; |
634 if (value.IsEmpty() || EqualIgnoringCase(value, "true")) | 635 if (value.IsEmpty() || DeprecatedEqualIgnoringCase(value, "true")) |
635 return "true"; | 636 return "true"; |
636 if (EqualIgnoringCase(value, "false")) | 637 if (DeprecatedEqualIgnoringCase(value, "false")) |
637 return "false"; | 638 return "false"; |
638 if (EqualIgnoringCase(value, "plaintext-only")) | 639 if (DeprecatedEqualIgnoringCase(value, "plaintext-only")) |
639 return "plaintext-only"; | 640 return "plaintext-only"; |
640 | 641 |
641 return "inherit"; | 642 return "inherit"; |
642 } | 643 } |
643 | 644 |
644 void HTMLElement::setContentEditable(const String& enabled, | 645 void HTMLElement::setContentEditable(const String& enabled, |
645 ExceptionState& exception_state) { | 646 ExceptionState& exception_state) { |
646 if (EqualIgnoringCase(enabled, "true")) | 647 if (DeprecatedEqualIgnoringCase(enabled, "true")) |
647 setAttribute(contenteditableAttr, "true"); | 648 setAttribute(contenteditableAttr, "true"); |
648 else if (EqualIgnoringCase(enabled, "false")) | 649 else if (DeprecatedEqualIgnoringCase(enabled, "false")) |
649 setAttribute(contenteditableAttr, "false"); | 650 setAttribute(contenteditableAttr, "false"); |
650 else if (EqualIgnoringCase(enabled, "plaintext-only")) | 651 else if (DeprecatedEqualIgnoringCase(enabled, "plaintext-only")) |
651 setAttribute(contenteditableAttr, "plaintext-only"); | 652 setAttribute(contenteditableAttr, "plaintext-only"); |
652 else if (EqualIgnoringCase(enabled, "inherit")) | 653 else if (DeprecatedEqualIgnoringCase(enabled, "inherit")) |
653 removeAttribute(contenteditableAttr); | 654 removeAttribute(contenteditableAttr); |
654 else | 655 else |
655 exception_state.ThrowDOMException(kSyntaxError, | 656 exception_state.ThrowDOMException(kSyntaxError, |
656 "The value provided ('" + enabled + | 657 "The value provided ('" + enabled + |
657 "') is not one of 'true', 'false', " | 658 "') is not one of 'true', 'false', " |
658 "'plaintext-only', or 'inherit'."); | 659 "'plaintext-only', or 'inherit'."); |
659 } | 660 } |
660 | 661 |
661 bool HTMLElement::isContentEditableForBinding() const { | 662 bool HTMLElement::isContentEditableForBinding() const { |
662 return IsEditingHost(*this) || IsEditable(*this); | 663 return IsEditingHost(*this) || IsEditable(*this); |
663 } | 664 } |
664 | 665 |
665 bool HTMLElement::draggable() const { | 666 bool HTMLElement::draggable() const { |
666 return EqualIgnoringCase(getAttribute(draggableAttr), "true"); | 667 return DeprecatedEqualIgnoringCase(getAttribute(draggableAttr), "true"); |
667 } | 668 } |
668 | 669 |
669 void HTMLElement::setDraggable(bool value) { | 670 void HTMLElement::setDraggable(bool value) { |
670 setAttribute(draggableAttr, value ? "true" : "false"); | 671 setAttribute(draggableAttr, value ? "true" : "false"); |
671 } | 672 } |
672 | 673 |
673 bool HTMLElement::spellcheck() const { | 674 bool HTMLElement::spellcheck() const { |
674 return IsSpellCheckingEnabled(); | 675 return IsSpellCheckingEnabled(); |
675 } | 676 } |
676 | 677 |
(...skipping 19 matching lines...) Expand all Loading... |
696 if (SupportsFocus()) | 697 if (SupportsFocus()) |
697 return Element::tabIndex(); | 698 return Element::tabIndex(); |
698 return -1; | 699 return -1; |
699 } | 700 } |
700 | 701 |
701 TranslateAttributeMode HTMLElement::GetTranslateAttributeMode() const { | 702 TranslateAttributeMode HTMLElement::GetTranslateAttributeMode() const { |
702 const AtomicString& value = getAttribute(translateAttr); | 703 const AtomicString& value = getAttribute(translateAttr); |
703 | 704 |
704 if (value == g_null_atom) | 705 if (value == g_null_atom) |
705 return kTranslateAttributeInherit; | 706 return kTranslateAttributeInherit; |
706 if (EqualIgnoringCase(value, "yes") || EqualIgnoringCase(value, "")) | 707 if (DeprecatedEqualIgnoringCase(value, "yes") || |
| 708 DeprecatedEqualIgnoringCase(value, "")) |
707 return kTranslateAttributeYes; | 709 return kTranslateAttributeYes; |
708 if (EqualIgnoringCase(value, "no")) | 710 if (DeprecatedEqualIgnoringCase(value, "no")) |
709 return kTranslateAttributeNo; | 711 return kTranslateAttributeNo; |
710 | 712 |
711 return kTranslateAttributeInherit; | 713 return kTranslateAttributeInherit; |
712 } | 714 } |
713 | 715 |
714 bool HTMLElement::translate() const { | 716 bool HTMLElement::translate() const { |
715 for (const HTMLElement* element = this; element; | 717 for (const HTMLElement* element = this; element; |
716 element = Traversal<HTMLElement>::FirstAncestor(*element)) { | 718 element = Traversal<HTMLElement>::FirstAncestor(*element)) { |
717 TranslateAttributeMode mode = element->GetTranslateAttributeMode(); | 719 TranslateAttributeMode mode = element->GetTranslateAttributeMode(); |
718 if (mode != kTranslateAttributeInherit) { | 720 if (mode != kTranslateAttributeInherit) { |
(...skipping 14 matching lines...) Expand all Loading... |
733 // in (in its canonical case), if any, or the empty string if the attribute is | 735 // in (in its canonical case), if any, or the empty string if the attribute is |
734 // in a state that has no associated keyword value or if the attribute is not in | 736 // in a state that has no associated keyword value or if the attribute is not in |
735 // a defined state (e.g. the attribute is missing and there is no missing value | 737 // a defined state (e.g. the attribute is missing and there is no missing value |
736 // default). | 738 // default). |
737 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interf
aces.html#limited-to-only-known-values | 739 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interf
aces.html#limited-to-only-known-values |
738 static inline const AtomicString& ToValidDirValue(const AtomicString& value) { | 740 static inline const AtomicString& ToValidDirValue(const AtomicString& value) { |
739 DEFINE_STATIC_LOCAL(const AtomicString, ltr_value, ("ltr")); | 741 DEFINE_STATIC_LOCAL(const AtomicString, ltr_value, ("ltr")); |
740 DEFINE_STATIC_LOCAL(const AtomicString, rtl_value, ("rtl")); | 742 DEFINE_STATIC_LOCAL(const AtomicString, rtl_value, ("rtl")); |
741 DEFINE_STATIC_LOCAL(const AtomicString, auto_value, ("auto")); | 743 DEFINE_STATIC_LOCAL(const AtomicString, auto_value, ("auto")); |
742 | 744 |
743 if (EqualIgnoringCase(value, ltr_value)) | 745 if (DeprecatedEqualIgnoringCase(value, ltr_value)) |
744 return ltr_value; | 746 return ltr_value; |
745 if (EqualIgnoringCase(value, rtl_value)) | 747 if (DeprecatedEqualIgnoringCase(value, rtl_value)) |
746 return rtl_value; | 748 return rtl_value; |
747 if (EqualIgnoringCase(value, auto_value)) | 749 if (DeprecatedEqualIgnoringCase(value, auto_value)) |
748 return auto_value; | 750 return auto_value; |
749 return g_null_atom; | 751 return g_null_atom; |
750 } | 752 } |
751 | 753 |
752 const AtomicString& HTMLElement::dir() { | 754 const AtomicString& HTMLElement::dir() { |
753 return ToValidDirValue(FastGetAttribute(dirAttr)); | 755 return ToValidDirValue(FastGetAttribute(dirAttr)); |
754 } | 756 } |
755 | 757 |
756 void HTMLElement::setDir(const AtomicString& value) { | 758 void HTMLElement::setDir(const AtomicString& value) { |
757 setAttribute(dirAttr, value); | 759 setAttribute(dirAttr, value); |
(...skipping 11 matching lines...) Expand all Loading... |
769 void HTMLElement::ChildrenChanged(const ChildrenChange& change) { | 771 void HTMLElement::ChildrenChanged(const ChildrenChange& change) { |
770 Element::ChildrenChanged(change); | 772 Element::ChildrenChanged(change); |
771 AdjustDirectionalityIfNeededAfterChildrenChanged(change); | 773 AdjustDirectionalityIfNeededAfterChildrenChanged(change); |
772 } | 774 } |
773 | 775 |
774 bool HTMLElement::HasDirectionAuto() const { | 776 bool HTMLElement::HasDirectionAuto() const { |
775 // <bdi> defaults to dir="auto" | 777 // <bdi> defaults to dir="auto" |
776 // https://html.spec.whatwg.org/multipage/semantics.html#the-bdi-element | 778 // https://html.spec.whatwg.org/multipage/semantics.html#the-bdi-element |
777 const AtomicString& direction = FastGetAttribute(dirAttr); | 779 const AtomicString& direction = FastGetAttribute(dirAttr); |
778 return (isHTMLBDIElement(*this) && direction == g_null_atom) || | 780 return (isHTMLBDIElement(*this) && direction == g_null_atom) || |
779 EqualIgnoringCase(direction, "auto"); | 781 DeprecatedEqualIgnoringCase(direction, "auto"); |
780 } | 782 } |
781 | 783 |
782 TextDirection HTMLElement::DirectionalityIfhasDirAutoAttribute( | 784 TextDirection HTMLElement::DirectionalityIfhasDirAutoAttribute( |
783 bool& is_auto) const { | 785 bool& is_auto) const { |
784 is_auto = HasDirectionAuto(); | 786 is_auto = HasDirectionAuto(); |
785 if (!is_auto) | 787 if (!is_auto) |
786 return TextDirection::kLtr; | 788 return TextDirection::kLtr; |
787 return Directionality(); | 789 return Directionality(); |
788 } | 790 } |
789 | 791 |
790 TextDirection HTMLElement::Directionality( | 792 TextDirection HTMLElement::Directionality( |
791 Node** strong_directionality_text_node) const { | 793 Node** strong_directionality_text_node) const { |
792 if (isHTMLInputElement(*this)) { | 794 if (isHTMLInputElement(*this)) { |
793 HTMLInputElement* input_element = | 795 HTMLInputElement* input_element = |
794 toHTMLInputElement(const_cast<HTMLElement*>(this)); | 796 toHTMLInputElement(const_cast<HTMLElement*>(this)); |
795 bool has_strong_directionality; | 797 bool has_strong_directionality; |
796 TextDirection text_direction = DetermineDirectionality( | 798 TextDirection text_direction = DetermineDirectionality( |
797 input_element->value(), &has_strong_directionality); | 799 input_element->value(), &has_strong_directionality); |
798 if (strong_directionality_text_node) | 800 if (strong_directionality_text_node) |
799 *strong_directionality_text_node = | 801 *strong_directionality_text_node = |
800 has_strong_directionality ? input_element : 0; | 802 has_strong_directionality ? input_element : 0; |
801 return text_direction; | 803 return text_direction; |
802 } | 804 } |
803 | 805 |
804 Node* node = FlatTreeTraversal::FirstChild(*this); | 806 Node* node = FlatTreeTraversal::FirstChild(*this); |
805 while (node) { | 807 while (node) { |
806 // Skip bdi, script, style and text form controls. | 808 // Skip bdi, script, style and text form controls. |
807 if (EqualIgnoringCase(node->nodeName(), "bdi") || | 809 if (DeprecatedEqualIgnoringCase(node->nodeName(), "bdi") || |
808 isHTMLScriptElement(*node) || isHTMLStyleElement(*node) || | 810 isHTMLScriptElement(*node) || isHTMLStyleElement(*node) || |
809 (node->IsElementNode() && ToElement(node)->IsTextControl()) || | 811 (node->IsElementNode() && ToElement(node)->IsTextControl()) || |
810 (node->IsElementNode() && | 812 (node->IsElementNode() && |
811 ToElement(node)->ShadowPseudoId() == "-webkit-input-placeholder")) { | 813 ToElement(node)->ShadowPseudoId() == "-webkit-input-placeholder")) { |
812 node = FlatTreeTraversal::NextSkippingChildren(*node, this); | 814 node = FlatTreeTraversal::NextSkippingChildren(*node, this); |
813 continue; | 815 continue; |
814 } | 816 } |
815 | 817 |
816 // Skip elements with valid dir attribute | 818 // Skip elements with valid dir attribute |
817 if (node->IsElementNode()) { | 819 if (node->IsElementNode()) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 // changes to dir attribute may affect the ancestor. | 856 // changes to dir attribute may affect the ancestor. |
855 if (!CanParticipateInFlatTree()) | 857 if (!CanParticipateInFlatTree()) |
856 return; | 858 return; |
857 UpdateDistribution(); | 859 UpdateDistribution(); |
858 Element* parent = FlatTreeTraversal::ParentElement(*this); | 860 Element* parent = FlatTreeTraversal::ParentElement(*this); |
859 if (parent && parent->IsHTMLElement() && | 861 if (parent && parent->IsHTMLElement() && |
860 ToHTMLElement(parent)->SelfOrAncestorHasDirAutoAttribute()) | 862 ToHTMLElement(parent)->SelfOrAncestorHasDirAutoAttribute()) |
861 ToHTMLElement(parent) | 863 ToHTMLElement(parent) |
862 ->AdjustDirectionalityIfNeededAfterChildAttributeChanged(this); | 864 ->AdjustDirectionalityIfNeededAfterChildAttributeChanged(this); |
863 | 865 |
864 if (EqualIgnoringCase(value, "auto")) | 866 if (DeprecatedEqualIgnoringCase(value, "auto")) |
865 CalculateAndAdjustDirectionality(); | 867 CalculateAndAdjustDirectionality(); |
866 } | 868 } |
867 | 869 |
868 void HTMLElement::AdjustDirectionalityIfNeededAfterChildAttributeChanged( | 870 void HTMLElement::AdjustDirectionalityIfNeededAfterChildAttributeChanged( |
869 Element* child) { | 871 Element* child) { |
870 DCHECK(SelfOrAncestorHasDirAutoAttribute()); | 872 DCHECK(SelfOrAncestorHasDirAutoAttribute()); |
871 const ComputedStyle* style = GetComputedStyle(); | 873 const ComputedStyle* style = GetComputedStyle(); |
872 if (style && style->Direction() != Directionality()) { | 874 if (style && style->Direction() != Directionality()) { |
873 for (Element* element_to_adjust = this; element_to_adjust; | 875 for (Element* element_to_adjust = this; element_to_adjust; |
874 element_to_adjust = | 876 element_to_adjust = |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 bool HTMLElement::ParseColorWithLegacyRules(const String& attribute_value, | 1004 bool HTMLElement::ParseColorWithLegacyRules(const String& attribute_value, |
1003 Color& parsed_color) { | 1005 Color& parsed_color) { |
1004 // An empty string doesn't apply a color. (One containing only whitespace | 1006 // An empty string doesn't apply a color. (One containing only whitespace |
1005 // does, which is why this check occurs before stripping.) | 1007 // does, which is why this check occurs before stripping.) |
1006 if (attribute_value.IsEmpty()) | 1008 if (attribute_value.IsEmpty()) |
1007 return false; | 1009 return false; |
1008 | 1010 |
1009 String color_string = attribute_value.StripWhiteSpace(); | 1011 String color_string = attribute_value.StripWhiteSpace(); |
1010 | 1012 |
1011 // "transparent" doesn't apply a color either. | 1013 // "transparent" doesn't apply a color either. |
1012 if (EqualIgnoringCase(color_string, "transparent")) | 1014 if (DeprecatedEqualIgnoringCase(color_string, "transparent")) |
1013 return false; | 1015 return false; |
1014 | 1016 |
1015 // If the string is a 3/6-digit hex color or a named CSS color, use that. | 1017 // If the string is a 3/6-digit hex color or a named CSS color, use that. |
1016 // Apply legacy rules otherwise. Note color.setFromString() accepts 4/8-digit | 1018 // Apply legacy rules otherwise. Note color.setFromString() accepts 4/8-digit |
1017 // hex color, so restrict its use with length checks here to support legacy | 1019 // hex color, so restrict its use with length checks here to support legacy |
1018 // HTML attributes. | 1020 // HTML attributes. |
1019 | 1021 |
1020 bool success = false; | 1022 bool success = false; |
1021 if ((color_string.length() == 4 || color_string.length() == 7) && | 1023 if ((color_string.length() == 4 || color_string.length() == 7) && |
1022 color_string[0] == '#') | 1024 color_string[0] == '#') |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 } | 1101 } |
1100 | 1102 |
1101 bool HTMLElement::MatchesReadOnlyPseudoClass() const { | 1103 bool HTMLElement::MatchesReadOnlyPseudoClass() const { |
1102 return !MatchesReadWritePseudoClass(); | 1104 return !MatchesReadWritePseudoClass(); |
1103 } | 1105 } |
1104 | 1106 |
1105 bool HTMLElement::MatchesReadWritePseudoClass() const { | 1107 bool HTMLElement::MatchesReadWritePseudoClass() const { |
1106 if (FastHasAttribute(contenteditableAttr)) { | 1108 if (FastHasAttribute(contenteditableAttr)) { |
1107 const AtomicString& value = FastGetAttribute(contenteditableAttr); | 1109 const AtomicString& value = FastGetAttribute(contenteditableAttr); |
1108 | 1110 |
1109 if (value.IsEmpty() || EqualIgnoringCase(value, "true") || | 1111 if (value.IsEmpty() || DeprecatedEqualIgnoringCase(value, "true") || |
1110 EqualIgnoringCase(value, "plaintext-only")) | 1112 DeprecatedEqualIgnoringCase(value, "plaintext-only")) |
1111 return true; | 1113 return true; |
1112 if (EqualIgnoringCase(value, "false")) | 1114 if (DeprecatedEqualIgnoringCase(value, "false")) |
1113 return false; | 1115 return false; |
1114 // All other values should be treated as "inherit". | 1116 // All other values should be treated as "inherit". |
1115 } | 1117 } |
1116 | 1118 |
1117 return parentElement() && HasEditableStyle(*parentElement()); | 1119 return parentElement() && HasEditableStyle(*parentElement()); |
1118 } | 1120 } |
1119 | 1121 |
1120 void HTMLElement::HandleKeypressEvent(KeyboardEvent* event) { | 1122 void HTMLElement::HandleKeypressEvent(KeyboardEvent* event) { |
1121 if (!IsSpatialNavigationEnabled(GetDocument().GetFrame()) || !SupportsFocus()) | 1123 if (!IsSpatialNavigationEnabled(GetDocument().GetFrame()) || !SupportsFocus()) |
1122 return; | 1124 return; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 | 1198 |
1197 #ifndef NDEBUG | 1199 #ifndef NDEBUG |
1198 | 1200 |
1199 // For use in the debugger | 1201 // For use in the debugger |
1200 void dumpInnerHTML(blink::HTMLElement*); | 1202 void dumpInnerHTML(blink::HTMLElement*); |
1201 | 1203 |
1202 void dumpInnerHTML(blink::HTMLElement* element) { | 1204 void dumpInnerHTML(blink::HTMLElement* element) { |
1203 printf("%s\n", element->innerHTML().Ascii().Data()); | 1205 printf("%s\n", element->innerHTML().Ascii().Data()); |
1204 } | 1206 } |
1205 #endif | 1207 #endif |
OLD | NEW |