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

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

Issue 198553002: Use new is*Element() helper functions even more in HTML code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLDocument.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 626 }
627 627
628 void HTMLElement::setTranslate(bool enable) 628 void HTMLElement::setTranslate(bool enable)
629 { 629 {
630 setAttribute(translateAttr, enable ? "yes" : "no"); 630 setAttribute(translateAttr, enable ? "yes" : "no");
631 } 631 }
632 632
633 HTMLFormElement* HTMLElement::findFormAncestor() const 633 HTMLFormElement* HTMLElement::findFormAncestor() const
634 { 634 {
635 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor-> parentNode()) { 635 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor-> parentNode()) {
636 if (ancestor->hasTagName(formTag)) 636 if (isHTMLFormElement(*ancestor))
637 return toHTMLFormElement(ancestor); 637 return toHTMLFormElement(ancestor);
638 } 638 }
639 return 0; 639 return 0;
640 } 640 }
641 641
642 static inline bool elementAffectsDirectionality(const Node* node) 642 static inline bool elementAffectsDirectionality(const Node* node)
643 { 643 {
644 return node->isHTMLElement() && (node->hasTagName(bdiTag) || toHTMLElement(n ode)->hasAttribute(dirAttr)); 644 return node->isHTMLElement() && (isHTMLBDIElement(*node) || toHTMLElement(no de)->hasAttribute(dirAttr));
645 } 645 }
646 646
647 static void setHasDirAutoFlagRecursively(Node* firstNode, bool flag, Node* lastN ode = 0) 647 static void setHasDirAutoFlagRecursively(Node* firstNode, bool flag, Node* lastN ode = 0)
648 { 648 {
649 firstNode->setSelfOrAncestorHasDirAutoAttribute(flag); 649 firstNode->setSelfOrAncestorHasDirAutoAttribute(flag);
650 650
651 Node* node = firstNode->firstChild(); 651 Node* node = firstNode->firstChild();
652 652
653 while (node) { 653 while (node) {
654 if (node->selfOrAncestorHasDirAutoAttribute() == flag) 654 if (node->selfOrAncestorHasDirAutoAttribute() == flag)
(...skipping 14 matching lines...) Expand all
669 669
670 void HTMLElement::childrenChanged(bool changedByParser, Node* beforeChange, Node * afterChange, int childCountDelta) 670 void HTMLElement::childrenChanged(bool changedByParser, Node* beforeChange, Node * afterChange, int childCountDelta)
671 { 671 {
672 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo untDelta); 672 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo untDelta);
673 adjustDirectionalityIfNeededAfterChildrenChanged(beforeChange, childCountDel ta); 673 adjustDirectionalityIfNeededAfterChildrenChanged(beforeChange, childCountDel ta);
674 } 674 }
675 675
676 bool HTMLElement::hasDirectionAuto() const 676 bool HTMLElement::hasDirectionAuto() const
677 { 677 {
678 const AtomicString& direction = fastGetAttribute(dirAttr); 678 const AtomicString& direction = fastGetAttribute(dirAttr);
679 return (hasTagName(bdiTag) && direction == nullAtom) || equalIgnoringCase(di rection, "auto"); 679 return (isHTMLBDIElement(*this) && direction == nullAtom) || equalIgnoringCa se(direction, "auto");
680 } 680 }
681 681
682 TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con st 682 TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con st
683 { 683 {
684 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { 684 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) {
685 isAuto = false; 685 isAuto = false;
686 return LTR; 686 return LTR;
687 } 687 }
688 688
689 isAuto = true; 689 isAuto = true;
690 return directionality(); 690 return directionality();
691 } 691 }
692 692
693 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst 693 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst
694 { 694 {
695 if (hasTagName(inputTag)) { 695 if (isHTMLInputElement(*this)) {
696 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); 696 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this));
697 bool hasStrongDirectionality; 697 bool hasStrongDirectionality;
698 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality); 698 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality);
699 if (strongDirectionalityTextNode) 699 if (strongDirectionalityTextNode)
700 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0; 700 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0;
701 return textDirection; 701 return textDirection;
702 } 702 }
703 703
704 Node* node = firstChild(); 704 Node* node = firstChild();
705 while (node) { 705 while (node) {
706 // Skip bdi, script, style and text form controls. 706 // Skip bdi, script, style and text form controls.
707 if (equalIgnoringCase(node->nodeName(), "bdi") || node->hasTagName(scrip tTag) || node->hasTagName(styleTag) 707 if (equalIgnoringCase(node->nodeName(), "bdi") || isHTMLScriptElement(*n ode) || isHTMLStyleElement(*node)
708 || (node->isElementNode() && toElement(node)->isTextFormControl())) { 708 || (node->isElementNode() && toElement(node)->isTextFormControl())) {
709 node = NodeTraversal::nextSkippingChildren(*node, this); 709 node = NodeTraversal::nextSkippingChildren(*node, this);
710 continue; 710 continue;
711 } 711 }
712 712
713 // Skip elements with valid dir attribute 713 // Skip elements with valid dir attribute
714 if (node->isElementNode()) { 714 if (node->isElementNode()) {
715 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d irAttr); 715 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d irAttr);
716 if (isValidDirAttribute(dirAttributeValue)) { 716 if (isValidDirAttribute(dirAttributeValue)) {
717 node = NodeTraversal::nextSkippingChildren(*node, this); 717 node = NodeTraversal::nextSkippingChildren(*node, this);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 #ifndef NDEBUG 968 #ifndef NDEBUG
969 969
970 // For use in the debugger 970 // For use in the debugger
971 void dumpInnerHTML(WebCore::HTMLElement*); 971 void dumpInnerHTML(WebCore::HTMLElement*);
972 972
973 void dumpInnerHTML(WebCore::HTMLElement* element) 973 void dumpInnerHTML(WebCore::HTMLElement* element)
974 { 974 {
975 printf("%s\n", element->innerHTML().ascii().data()); 975 printf("%s\n", element->innerHTML().ascii().data());
976 } 976 }
977 #endif 977 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLDocument.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698