Skip to content
  • commit-queue@webkit.org's avatar
    Improve srcset parser · ccd2f459
    commit-queue@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=119423
    
    Patch by Romain Perier <romain.perier@gmail.com> on 2013-09-17
    Reviewed by Benjamin Poulain.
    
    Source/WebCore:
    
    Added new tests and covered by existing ones.
    
    * html/parser/HTMLParserIdioms.cpp:
    (WebCore::isHTMLSpaceOrComma): Add a new predicate function used by String::find()
    to get the first space or comma character from the input string.
    (WebCore::parseImagesWithScaleFromSrcSetAttribute): Add a new static function to parse
    and extract images with scale from the srcset attribute. All valid candidates are
    returned to the caller through a list. This parsing function also adds support
    for data URI schemes as described by the specification.
    (WebCore::bestFitSourceForImageAttributes): Remove intermediate arrays of string
    when parsing. That is more efficient and avoids trashing the data cache
    (varying between 20 and 65% faster depending of the amount of data)
    The parser now walks along the attribute value and extracts the candidates directly.
    
    LayoutTests:
    
    * fast/hidpi/image-srcset-data-srcset-invalid-inputs.html: Ensures that a various invalid
      form of data uri schemes are supported by the srcset attribute.
    * fast/hidpi/image-srcset-data-srcset-valid-inputs.html: Ensures that a various valid
      form of data uri schemes are supported by the srcset attribute.
    * fast/hidpi/image-srcset-data-srcset.html: Use comma instead of %.
    * fast/hidpi/image-srcset-fraction-1.5x.html: Added.
    * fast/hidpi/image-srcset-invalid-inputs-except-one.html: Missing srcset-helper.js. Adding more invalid cases.
    * fast/hidpi/image-srcset-invalid-inputs.html: Adding more invalid cases.
    * fast/hidpi/image-srcset-nomodifier.html: Updated output as behaviour changed for this case.
    * fast/hidpi/image-srcset-space-suffix-nomodifier.html: Ensures that a single candidate with no scale modifier
      is supported by the srcset attribute, even if a space is left at the end.
    * fast/hidpi/image-srcset-space-prefix-nomodifier.html: Ensures that a single candidate with no scale modifier
      is supported by the srcset attribute, even if a space is left at the beginning.
    * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: Ensures that a single candidate with no scale modifier
      is supported by the srcset attribute, even if it is surrounded by spaces.
    * fast/hidpi/image-srcset-data-escaped-srcset.html: Ensures that data uri schemes with escaped characters
      are supported by the srcset attribute.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155988 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    ccd2f459