Skip to content
  • rniwa@webkit.org's avatar
    BDI element should have dir=auto by default · 00fa4f3a
    rniwa@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=68773
    
    Reviewed by Daniel Bates.
    
    Source/WebCore: 
    
    Treat bdi elements without dir content attribute as if they have dir=auto per spec:
    http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-bdi-element
    
    The patch tries to encapsulate the logic to look for dir content attribute and dir=auto.
    
    It also adds HTMLBDIElement interface (binding remains to use HTMLElement) to set
    selfOrAncestorHasDirAutoAttribute flag true by default, which is used by functions like
    directionalityIfhasDirAutoAttribute to look for elements with dir=auto. Since dir=auto-ness of bdi
    elements can be overridden by dir content attribute, we must change and only change the default value.
    
    Tests: fast/text/international/bdi-dir-default-to-auto-expected.html
           fast/text/international/bdi-dir-default-to-auto.html
    
    * GNUmakefile.list.am:
    * Target.pri:
    * WebCore.gypi:
    * WebCore.vcproj/WebCore.vcproj:
    * WebCore.xcodeproj/project.pbxproj:
    * css/CSSStyleSelector.cpp:
    (WebCore::CSSStyleSelector::collectMatchingRulesForList):
    * html/HTMLBDIElement.h: Added.
    (WebCore):
    (HTMLBDIElement):
    (WebCore::HTMLBDIElement::create):
    (WebCore::HTMLBDIElement::HTMLBDIElement): Sets selfOrAncestorHasDirAutoAttribute to true because
    bdi elements are treated as if it has dir=auto by default.
    * html/HTMLElement.cpp:
    (WebCore::elementAffectsDirectionality): Added. Checks if the specified element is bdi or
    has dir content attribute.
    (WebCore):
    (WebCore::setHasDirAutoFlagRecursively):
    (WebCore::HTMLElement::hasDirectionAuto): Added. Checks if the specified element should be treated
    as if it has dir=auto (bdi or element with dir=auto).
    (WebCore::HTMLElement::directionalityIfhasDirAutoAttribute):
    (WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged):
    (WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildrenChanged):
    * html/HTMLElement.h:
    (HTMLElement):
    * html/HTMLTagNames.in: Use HTMLBDIElement instead of HTMLElement for constructing bdi element
    to set selfOrAncestorHasDirAutoAttribute true but still use HTMLElement for binding.
    
    LayoutTests: 
    
    Add a test written by Aharon Lanin.
    
    * fast/text/international/bdi-dir-default-to-auto-expected.html: Added.
    * fast/text/international/bdi-dir-default-to-auto.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@111632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    00fa4f3a