Class: Hatemile::Implementation::AccessibleCSSImplementation
- Inherits:
-
AccessibleCSS
- Object
- AccessibleCSS
- Hatemile::Implementation::AccessibleCSSImplementation
- Defined in:
- lib/hatemile/implementation/accessible_css_implementation.rb
Overview
The AccessibleCSSImplementation class is official implementation of AccessibleCSS.
Constant Summary collapse
- DATA_ISOLATOR_ELEMENT =
The name of attribute for identify isolator elements.
'data-auxiliarspan'.freeze
- DATA_SPEAK =
The name of attribute for identify the element created or modified to support speak property.
'data-cssspeak'.freeze
- DATA_SPEAK_AS =
The name of attribute for identify the element created or modified to support speak-as property.
'data-cssspeakas'.freeze
- VALID_INHERIT_TAGS =
The valid element tags for inherit the speak and speak-as properties.
%w[ SPAN A RT DFN ABBR Q CITE EM TIME VAR SAMP I B SUB SUP SMALL STRONG MARK RUBY INS DEL KBD BDO CODE P FIGCAPTION FIGURE PRE DIV OL UL LI BLOCKQUOTE DL DT DD FIELDSET LEGEND LABEL FORM BODY ASIDE ADDRESS H1 H2 H3 H4 H5 H6 SECTION HEADER NAV ARTICLE FOOTER HGROUP CAPTION SUMMARY DETAILS TABLE TR TD TH TBODY THEAD TFOOT ].freeze
- VALID_TAGS =
The valid element tags for speak and speak-as properties.
%w[ SPAN A RT DFN ABBR Q CITE EM TIME VAR SAMP I B SUB SUP SMALL STRONG MARK RUBY INS DEL KBD BDO CODE P FIGCAPTION FIGURE PRE DIV LI BLOCKQUOTE DT DD FIELDSET LEGEND LABEL FORM BODY ASIDE ADDRESS H1 H2 H3 H4 H5 H6 SECTION HEADER NAV ARTICLE FOOTER CAPTION SUMMARY DETAILS TD TH ].freeze
Instance Method Summary collapse
-
#initialize(html_parser, css_parser, configure, symbol_file_name = nil) ⇒ AccessibleCSSImplementation
constructor
Initializes a new object that improve the accessibility of associations of parser.
- #provide_all_speak_properties ⇒ Object
- #provide_speak_properties(element) ⇒ Object
Constructor Details
#initialize(html_parser, css_parser, configure, symbol_file_name = nil) ⇒ AccessibleCSSImplementation
Initializes a new object that improve the accessibility of associations of parser.
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
# File 'lib/hatemile/implementation/accessible_css_implementation.rb', line 710 def initialize(html_parser, css_parser, configure, symbol_file_name = nil) Hatemile::Helper.require_not_nil(html_parser, css_parser, configure) Hatemile::Helper.require_valid_type( html_parser, Hatemile::Util::Html::HTMLDOMParser ) Hatemile::Helper.require_valid_type( css_parser, Hatemile::Util::Css::StyleSheetParser ) Hatemile::Helper.require_valid_type( configure, Hatemile::Util::Configure ) Hatemile::Helper.require_valid_type(symbol_file_name, String) @html_parser = html_parser @css_parser = css_parser @configure = configure @id_generator = Hatemile::Util::IDGenerator.new('css') set_symbols(symbol_file_name) end |
Instance Method Details
#provide_all_speak_properties ⇒ Object
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
# File 'lib/hatemile/implementation/accessible_css_implementation.rb', line 749 def provide_all_speak_properties selector = nil rules = @css_parser.get_rules( %w[speak speak-punctuation speak-numeral speak-header speak-as] ) rules.each do |rule| selector = if selector.nil? rule.get_selector else "#{selector},#{rule.get_selector}" end end return if selector.nil? @html_parser.find(selector).list_results.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) provide_speak_properties(element) end end end |
#provide_speak_properties(element) ⇒ Object
735 736 737 738 739 740 741 742 743 744 745 |
# File 'lib/hatemile/implementation/accessible_css_implementation.rb', line 735 def provide_speak_properties(element) rules = @css_parser.get_rules( %w[speak speak-punctuation speak-numeral speak-header speak-as] ) rules.each do |rule| speak_elements = @html_parser.find(rule.get_selector).list_results if speak_elements.include?(element) provide_speak_properties_with_rule(element, rule) end end end |