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

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

Issue 524593003: Resolve direction correctly when dir attribute is not in a defined state Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix failing test Created 6 years, 1 month 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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 692 }
693 693
694 HTMLTextFormControlElement* enclosingTextFormControl(Node* container) 694 HTMLTextFormControlElement* enclosingTextFormControl(Node* container)
695 { 695 {
696 if (!container) 696 if (!container)
697 return nullptr; 697 return nullptr;
698 Element* ancestor = container->shadowHost(); 698 Element* ancestor = container->shadowHost();
699 return ancestor && isHTMLTextFormControlElement(*ancestor) && container->con tainingShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot ? toHTMLTextFormC ontrolElement(ancestor) : 0; 699 return ancestor && isHTMLTextFormControlElement(*ancestor) && container->con tainingShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot ? toHTMLTextFormC ontrolElement(ancestor) : 0;
700 } 700 }
701 701
702 String HTMLTextFormControlElement::directionForFormData() const
703 {
704 for (const HTMLElement* element = this; element; element = Traversal<HTMLEle ment>::firstAncestor(*element)) {
705 const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAtt r);
706 if (dirAttributeValue.isNull())
707 continue;
708
709 if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dir AttributeValue, "ltr"))
710 return dirAttributeValue;
711
712 if (equalIgnoringCase(dirAttributeValue, "auto")) {
713 bool isAuto;
714 TextDirection textDirection = element->directionalityIfhasDirAutoAtt ribute(isAuto);
715 return textDirection == RTL ? "rtl" : "ltr";
716 }
717 }
718
719 return "ltr";
720 }
721
722 HTMLElement* HTMLTextFormControlElement::innerEditorElement() const 702 HTMLElement* HTMLTextFormControlElement::innerEditorElement() const
723 { 703 {
724 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor())); 704 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor()));
725 } 705 }
726 706
727 static Position innerNodePosition(const Position& innerPosition) 707 static Position innerNodePosition(const Position& innerPosition)
728 { 708 {
729 ASSERT(innerPosition.anchorType() != Position::PositionIsBeforeAnchor); 709 ASSERT(innerPosition.anchorType() != Position::PositionIsBeforeAnchor);
730 ASSERT(innerPosition.anchorType() != Position::PositionIsAfterAnchor); 710 ASSERT(innerPosition.anchorType() != Position::PositionIsAfterAnchor);
731 HTMLElement* element = toHTMLElement(innerPosition.anchorNode()); 711 HTMLElement* element = toHTMLElement(innerPosition.anchorNode());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 Text* textNode = toText(node); 937 Text* textNode = toText(node);
958 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi votPosition.offsetInContainerNode() : 0); 938 size_t firstLineBreak = textNode->data().find('\n', isPivotNode ? pi votPosition.offsetInContainerNode() : 0);
959 if (firstLineBreak != kNotFound) 939 if (firstLineBreak != kNotFound)
960 return Position(textNode, firstLineBreak + 1); 940 return Position(textNode, firstLineBreak + 1);
961 } 941 }
962 } 942 }
963 return endOfInnerText(textFormControl); 943 return endOfInnerText(textFormControl);
964 } 944 }
965 945
966 } // namespace blink 946 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698