WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Work In Progress
fix-64861.patch (text/plain), 13.08 KB, created by
Sylvain Galineau
on 2015-04-28 17:48:14 PDT
(
hide
)
Description:
Work In Progress
Filename:
MIME Type:
Creator:
Sylvain Galineau
Created:
2015-04-28 17:48:14 PDT
Size:
13.08 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b3a107c..f8cde75 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,40 @@ >+2015-04-28 sylvain-galineau <galineau@adobe.com> >+ >+ >+ Need support for :dir() pseudo-class >+ https://bugs.webkit.org/show_bug.cgi?id=64861 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add :dir() pseudo-class support as defined by CSS, HTML >+ http://dev.w3.org/csswg/selectors-4/#the-dir-pseudo >+ https://html.spec.whatwg.org/multipage/scripting.html#selectors >+ https://html.spec.whatwg.org/multipage/dom.html#the-directionality >+ >+ No new tests (OOPS!). >+ >+ * css/CSSSelector.cpp: >+ (WebCore::CSSSelector::parseDirection): >+ * css/CSSSelector.h: >+ parse :dir() argument >+ * css/SelectorChecker.cpp: >+ match :dir() with element's directionality >+ * dom/Element.cpp: >+ (WebCore::Element::selfDirectionality): >+ (WebCore::Element::computeInheritedDirectionality): >+ (WebCore::Element::evalContentDirectionality): >+ Compute element directionality >+ * dom/Element.h: >+ (WebCore::Element::hasDefaultDirectionality): >+ Whether an element has a base direction e.g. telephone field >+ * html/HTMLInputElement.cpp: >+ (WebCore::HTMLInputElement::evalContentDirectionality): >+ * html/HTMLInputElement.h: >+ * html/HTMLTextFormControlElement.cpp: >+ (WebCore::HTMLTextFormControlElement::evalContentDirectionality): >+ * html/HTMLTextFormControlElement.h: >+ Compute element directionality for form fields >+ > 2015-04-28 Alex Christensen <achristensen@webkit.org> > > [Content Extensions] Use less memory for CombinedURLFilters. >diff --git a/Source/WebCore/css/CSSSelector.cpp b/Source/WebCore/css/CSSSelector.cpp >index 7081926..8e54bdc 100644 >--- a/Source/WebCore/css/CSSSelector.cpp >+++ b/Source/WebCore/css/CSSSelector.cpp >@@ -320,7 +320,17 @@ CSSSelector::PseudoElementType CSSSelector::parsePseudoElementType(const String& > return type; > } > >- >+CSSSelector::Directionality CSSSelector::parseDirection(const AtomicString& name) >+{ >+ if (equalIgnoringCase(name, "ltr")) { >+ return Directionality::LTR; >+ } else if (equalIgnoringCase(name, "rtl")) { >+ return Directionality::RTL; >+ } >+ >+ return Directionality::Invalid; >+} >+ > bool CSSSelector::operator==(const CSSSelector& other) const > { > const CSSSelector* sel1 = this; >diff --git a/Source/WebCore/css/CSSSelector.h b/Source/WebCore/css/CSSSelector.h >index 4c347d2..397c072 100644 >--- a/Source/WebCore/css/CSSSelector.h >+++ b/Source/WebCore/css/CSSSelector.h >@@ -209,6 +209,14 @@ namespace WebCore { > > static PseudoElementType parsePseudoElementType(const String&); > static PseudoId pseudoId(PseudoElementType); >+#if ENABLE(CSS_SELECTORS_LEVEL4) >+ enum class Directionality { >+ Invalid, >+ LTR, >+ RTL >+ }; >+ static Directionality parseDirection(const AtomicString&); >+#endif > > // Selectors are kept in an array by CSSSelectorList. The next component of the selector is > // the next item in the array. >diff --git a/Source/WebCore/css/SelectorChecker.cpp b/Source/WebCore/css/SelectorChecker.cpp >index 8bfe02b..aac15dd 100644 >--- a/Source/WebCore/css/SelectorChecker.cpp >+++ b/Source/WebCore/css/SelectorChecker.cpp >@@ -55,6 +55,7 @@ > #include "ShadowRoot.h" > #include "StyledElement.h" > #include "Text.h" >+#include "TextFlags.h" > > namespace WebCore { > >@@ -205,6 +206,23 @@ inline static bool hasScrollbarPseudoElement(const PseudoIdSet& dynamicPseudoIdS > // because it can have more than one pseudo element. > return dynamicPseudoIdSet.has(RESIZER); > } >+ >+static bool operator==(const CSSSelector::Directionality& a, const TextDirection& b) >+{ >+ switch(a) { >+ case CSSSelector::Directionality::LTR: >+ return (b==LTR)?true:false; >+ >+ case CSSSelector::Directionality::RTL: >+ return (b==RTL)?true:false; >+ >+ case CSSSelector::Directionality::Invalid: >+ return false; >+ >+ default: >+ return false; >+ } >+} > > static SelectorChecker::CheckingContextWithStatus checkingContextForParent(const SelectorChecker::CheckingContextWithStatus& context) > { >@@ -1030,10 +1048,15 @@ bool SelectorChecker::checkOne(const CheckingContextWithStatus& context, PseudoI > return false; > > #if ENABLE(CSS_SELECTORS_LEVEL4) >- // FIXME: Implement :dir() selector. > case CSSSelector::PseudoClassDir: >- return false; >- >+ { >+ CSSSelector::Directionality selectorDirectionality = CSSSelector::parseDirection(selector->argument()); >+ if (selectorDirectionality == CSSSelector::Directionality::Invalid) >+ return false; >+ >+ return selectorDirectionality == element->computeInheritedDirectionality(); >+ } >+ > // FIXME: Implement :role() selector. > case CSSSelector::PseudoClassRole: > return false; >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index d4d8417..f1d24fd 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -2543,6 +2543,92 @@ Locale& Element::locale() const > { > return document().getCachedLocale(computeInheritedLanguage()); > } >+ >+Element::SelfDirectionality Element::selfDirectionality() const >+{ >+ static NeverDestroyed<AtomicString> ltrValue("ltr", AtomicString::ConstructFromLiteral); >+ static NeverDestroyed<AtomicString> rtlValue("rtl", AtomicString::ConstructFromLiteral); >+ static NeverDestroyed<AtomicString> autoValue("auto", AtomicString::ConstructFromLiteral); >+ const AtomicString& value = fastGetAttribute(dirAttr); >+ >+ if (equalIgnoringCase(value, ltrValue)) >+ return SelfDirectionality::DirLTR; >+ if (equalIgnoringCase(value, rtlValue)) >+ return SelfDirectionality::DirRTL; >+ if (equalIgnoringCase(value, autoValue)) >+ return SelfDirectionality::DirAuto; >+ >+ return SelfDirectionality::DirUnknown; >+} >+ >+TextDirection Element::computeInheritedDirectionality() const >+{ >+ SelfDirectionality directionality = selfDirectionality(); >+ TextDirection textDirection; >+ >+ if (directionality == SelfDirectionality::DirLTR) >+ return LTR; >+ >+ if (directionality == SelfDirectionality::DirRTL) >+ return RTL; >+ >+ if (directionality == SelfDirectionality::DirAuto) { >+ if (evalContentDirectionality(textDirection)) >+ return textDirection; >+ } >+ >+ if (directionality == SelfDirectionality::DirUnknown) { >+ //if (hasDefaultDirectionality(textDirection)) >+ // return textDirection; >+ >+ if (hasTagName(bdiTag) && evalContentDirectionality(textDirection)) >+ return textDirection; >+ } >+ >+ if (Element* parentElement = this->parentElement()) >+ return parentElement->computeInheritedDirectionality(); >+ >+ return LTR; >+} >+ >+bool Element::evalContentDirectionality(TextDirection& direction) const { >+ bool foundDirection = false; >+ UCharDirection charDirection; >+ >+ Node* node = firstChild(); >+ while (node) { >+ // Skip bdi, script, style and text form controls. >+ if (equalIgnoringCase(node->nodeName(), "bdi") || node->hasTagName(scriptTag) || node->hasTagName(styleTag) >+ || (is<Element>(*node) && downcast<Element>(*node).isTextFormControl())) { >+ node = NodeTraversal::nextSkippingChildren(*node, this); >+ continue; >+ } >+ >+ // Skip elements with valid dir attribute >+ if (is<Element>(*node)) { >+ Element& e = downcast<Element>(*node); >+ if (e.selfDirectionality() != SelfDirectionality::DirUnknown) { >+ node = NodeTraversal::nextSkippingChildren(*node, this); >+ continue; >+ } >+ } >+ >+ if (node->isTextNode()) { >+ bool hasStrongDirectionality; >+ charDirection = node->textContent(true).defaultWritingDirection(&hasStrongDirectionality); >+ foundDirection = true; >+ break; >+ } >+ node = NodeTraversal::next(*node, this); >+ } >+ >+ if (foundDirection) { >+ direction = (charDirection == U_LEFT_TO_RIGHT)? LTR : RTL; >+ } >+ >+ return foundDirection; >+} >+ > > void Element::cancelFocusAppearanceUpdate() > { >diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h >index d7fd199..63cce69 100644 >--- a/Source/WebCore/dom/Element.h >+++ b/Source/WebCore/dom/Element.h >@@ -33,6 +33,7 @@ > #include "ScrollTypes.h" > #include "SimulatedClickOptions.h" > #include "StyleResolveTree.h" >+#include "TextFlags.h" > > namespace WebCore { > >@@ -308,6 +309,10 @@ public: > > AtomicString computeInheritedLanguage() const; > Locale& locale() const; >+ >+ enum class SelfDirectionality { DirLTR, DirRTL, DirAuto, DirUnknown }; >+ SelfDirectionality selfDirectionality() const; >+ TextDirection computeInheritedDirectionality() const; > > virtual void accessKeyAction(bool /*sendToAnyEvent*/) { } > >@@ -514,6 +519,9 @@ protected: > void classAttributeChanged(const AtomicString& newClassString); > > static void mergeWithNextTextNode(Text& node, ExceptionCode&); >+ >+ virtual bool evalContentDirectionality(TextDirection& direction) const; >+ virtual bool hasDefaultDirectionality(TextDirection& direction) const { direction = LTR; return false; } > > private: > bool isTextNode() const; >diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp >index 7e037a9..0a2c468 100644 >--- a/Source/WebCore/html/HTMLInputElement.cpp >+++ b/Source/WebCore/html/HTMLInputElement.cpp >@@ -1922,5 +1922,25 @@ void HTMLInputElement::capsLockStateMayHaveChanged() > { > m_inputType->capsLockStateMayHaveChanged(); > } >+ >+bool HTMLInputElement::evalContentDirectionality(TextDirection& direction) const >+{ >+ bool hasDirectionality = false; >+ >+ if (isTextField() || isTelephoneField() || isSearchField() || >+ isURLField() || isEmailField() || is<HTMLTextAreaElement>(*this)) { >+ UCharDirection charDirection = this->value().defaultWritingDirection(&hasDirectionality); >+ >+ if (hasDirectionality) { >+ direction = (charDirection == U_LEFT_TO_RIGHT)? LTR : RTL; >+ return true; >+ } >+ } >+ >+ TextDirection fallbackDirection; >+ hasDirectionality = HTMLTextFormControlElement::evalContentDirectionality(fallbackDirection); >+ direction = fallbackDirection; >+ return hasDirectionality; >+} > > } // namespace >diff --git a/Source/WebCore/html/HTMLInputElement.h b/Source/WebCore/html/HTMLInputElement.h >index 9b27504..46a9f67 100644 >--- a/Source/WebCore/html/HTMLInputElement.h >+++ b/Source/WebCore/html/HTMLInputElement.h >@@ -326,6 +326,9 @@ protected: > HTMLInputElement(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser); > > virtual void defaultEventHandler(Event*) override; >+ >+ virtual bool evalContentDirectionality(TextDirection& direction) const override; >+ virtual bool hasDefaultDirectionality(TextDirection& direction) const override { direction = LTR; return isTelephoneField(); } > > private: > enum AutoCompleteSetting { Uninitialized, On, Off }; >@@ -420,7 +423,7 @@ private: > CheckedRadioButtons* checkedRadioButtons() const; > void addToRadioButtonGroup(); > void removeFromRadioButtonGroup(); >- >+ > AtomicString m_name; > String m_valueIfDirty; > int m_size; >diff --git a/Source/WebCore/html/HTMLTextFormControlElement.cpp b/Source/WebCore/html/HTMLTextFormControlElement.cpp >index 3684e28..b98cbc2 100644 >--- a/Source/WebCore/html/HTMLTextFormControlElement.cpp >+++ b/Source/WebCore/html/HTMLTextFormControlElement.cpp >@@ -760,5 +760,15 @@ String HTMLTextFormControlElement::directionForFormData() const > > return "ltr"; > } >+ >+bool HTMLTextFormControlElement::evalContentDirectionality(TextDirection& direction) const >+{ >+ if (this->value().isEmpty()) >+ return false; >+ else { >+ direction = LTR; >+ return true; >+ } >+} > > } // namespace Webcore >diff --git a/Source/WebCore/html/HTMLTextFormControlElement.h b/Source/WebCore/html/HTMLTextFormControlElement.h >index 2cea1be..bff53f1 100644 >--- a/Source/WebCore/html/HTMLTextFormControlElement.h >+++ b/Source/WebCore/html/HTMLTextFormControlElement.h >@@ -119,6 +119,8 @@ protected: > > String valueWithHardLineBreaks() const; > >+ virtual bool evalContentDirectionality(TextDirection& direction) const override; >+ > private: > TextFieldSelectionDirection cachedSelectionDirection() const { return static_cast<TextFieldSelectionDirection>(m_cachedSelectionDirection); } > >@@ -138,7 +140,7 @@ private: > virtual void handleFocusEvent(Node* /* oldFocusedNode */, FocusDirection) { } > // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent(). > virtual void handleBlurEvent() { } >- >+ > bool placeholderShouldBeVisible() const; > > String m_textAsOfLastFormControlChangeEvent;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 64861
:
242777
|
242815
|
248025
|
248159
|
248160
|
248164
|
248222
| 251902