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

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

Issue 240243004: Update HTMLElement.dir / Document.dir to return only known values (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use fastGetAttribute Created 6 years, 8 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/HTMLElement.h ('k') | Source/core/html/HTMLElement.idl » ('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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 622
623 // Default on the root element is translate=yes. 623 // Default on the root element is translate=yes.
624 return true; 624 return true;
625 } 625 }
626 626
627 void HTMLElement::setTranslate(bool enable) 627 void HTMLElement::setTranslate(bool enable)
628 { 628 {
629 setAttribute(translateAttr, enable ? "yes" : "no"); 629 setAttribute(translateAttr, enable ? "yes" : "no");
630 } 630 }
631 631
632 // Returns the conforming 'dir' value associated with the state the attribute is in (in its canonical case), if any,
633 // or the empty string if the attribute is in a state that has no associated key word value or if the attribute is
634 // not in a defined state (e.g. the attribute is missing and there is no missing value default).
635 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interf aces.html#limited-to-only-known-values
636 static inline const AtomicString& toValidDirValue(const AtomicString& value)
637 {
638 DEFINE_STATIC_LOCAL(const AtomicString, ltrValue, ("ltr", AtomicString::Cons tructFromLiteral));
639 DEFINE_STATIC_LOCAL(const AtomicString, rtlValue, ("rtl", AtomicString::Cons tructFromLiteral));
640 DEFINE_STATIC_LOCAL(const AtomicString, autoValue, ("auto", AtomicString::Co nstructFromLiteral));
641
642 if (equalIgnoringCase(value, ltrValue))
643 return ltrValue;
644 if (equalIgnoringCase(value, rtlValue))
645 return rtlValue;
646 if (equalIgnoringCase(value, autoValue))
647 return autoValue;
648 return nullAtom;
649 }
650
651 const AtomicString& HTMLElement::dir()
652 {
653 return toValidDirValue(fastGetAttribute(dirAttr));
654 }
655
656 void HTMLElement::setDir(const AtomicString& value)
657 {
658 setAttribute(dirAttr, value);
659 }
660
632 HTMLFormElement* HTMLElement::findFormAncestor() const 661 HTMLFormElement* HTMLElement::findFormAncestor() const
633 { 662 {
634 return Traversal<HTMLFormElement>::firstAncestor(*this); 663 return Traversal<HTMLFormElement>::firstAncestor(*this);
635 } 664 }
636 665
637 static inline bool elementAffectsDirectionality(const Node* node) 666 static inline bool elementAffectsDirectionality(const Node* node)
638 { 667 {
639 return node->isHTMLElement() && (isHTMLBDIElement(*node) || toHTMLElement(no de)->hasAttribute(dirAttr)); 668 return node->isHTMLElement() && (isHTMLBDIElement(*node) || toHTMLElement(no de)->hasAttribute(dirAttr));
640 } 669 }
641 670
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 #ifndef NDEBUG 993 #ifndef NDEBUG
965 994
966 // For use in the debugger 995 // For use in the debugger
967 void dumpInnerHTML(WebCore::HTMLElement*); 996 void dumpInnerHTML(WebCore::HTMLElement*);
968 997
969 void dumpInnerHTML(WebCore::HTMLElement* element) 998 void dumpInnerHTML(WebCore::HTMLElement* element)
970 { 999 {
971 printf("%s\n", element->innerHTML().ascii().data()); 1000 printf("%s\n", element->innerHTML().ascii().data());
972 } 1001 }
973 #endif 1002 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698