Changeset 230712 in webkit


Ignore:
Timestamp:
Apr 17, 2018 9:22:49 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Animated GIF imagery with finite looping are falling one loop short
https://bugs.webkit.org/show_bug.cgi?id=183153

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2018-04-17
Reviewed by Simon Fraser.

Source/WebCore:

The Netscape Looping Application Extension is a block which may be added
to a GIF file to tell the viewer to loop through the entire GIF frames.
This is communicated through two bytes designated for the "loopCount" in
this block.

The entire block may not be found in the GIF, in which case the GIF is
supposed to animate its entire frames only once.

If the block exists and loopCount = 0, this means the image has to loop
through its frames indefinitely.

If the block exist and loopCount > 0, this should mean the image has to
loop through its frames loopCount + 1 times. The extra loop seems to be
the consensus among most of the GIF generators and viewers. For example,
if the image designer wants the image to loop through its frames n times:
-- The GIF generator (e.g. Adobe Photoshop and https://ezgif.com/maker)

will write n - 1 for loopCount. However http://gifmaker.me and
http://gifmaker.org write n for loopCount.

-- The browser (e.g. Chrome 65.0.3325 181 and FireFox Quantum 59.0.2) will

translate loopCount = n - 1 to: animate GIF once + loop n - 1, which
means loop the GIF n times.

Because the specs are not really clear about this, we are going to consider
the agreed-upon behavior among most of the web browsers the specs here.

  • platform/graphics/cg/ImageDecoderCG.cpp:

(WebCore::ImageDecoderCG::repetitionCount const):

  • platform/image-decoders/gif/GIFImageDecoder.cpp:

(WebCore::GIFImageDecoder::repetitionCount const):

LayoutTests:

This layout test tests GIF when it has to loop its entire frames a specific
number of times. There are three cases for the loopCount field:
-- loopCount is missing: This means the GIF should animate only once. This

is covered by animated-red-green-blue-repeat-1.gif.

-- loopCount = 0: This means the image has to animate indefinatly. This

case is covered by the new GIF animated-red-green-blue-repeat-infinite.gif.

-- loopCount > 0: This will loop the GIF entire frames for (loopCount + 1)

times. To fix the test with the extra loop, loopCount in
animated-red-green-blue-repeat-2.gif was changed to 1 instead of 2.

  • fast/images/animated-image-loop-count-expected.html:
  • fast/images/animated-image-loop-count.html:
  • fast/images/resources/animated-red-green-blue-repeat-2.gif:
  • fast/images/resources/animated-red-green-blue-repeat-infinite.gif:
Location:
trunk
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r230703 r230712  
     12018-04-17  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Animated GIF imagery with finite looping are falling one loop short
     4        https://bugs.webkit.org/show_bug.cgi?id=183153
     5
     6        Reviewed by Simon Fraser.
     7
     8        This layout test tests GIF when it has to loop its entire frames a specific
     9        number of times. There are three cases for the loopCount field:
     10        -- loopCount is missing: This means the GIF should animate only once. This
     11           is covered by animated-red-green-blue-repeat-1.gif.
     12        -- loopCount = 0: This means the image has to animate indefinatly. This
     13           case is covered by the new GIF animated-red-green-blue-repeat-infinite.gif.
     14        -- loopCount > 0: This will loop the GIF entire frames for (loopCount + 1)
     15           times. To fix the test with the extra loop, loopCount in
     16           animated-red-green-blue-repeat-2.gif was changed to 1 instead of 2.
     17
     18        * fast/images/animated-image-loop-count-expected.html:
     19        * fast/images/animated-image-loop-count.html:
     20        * fast/images/resources/animated-red-green-blue-repeat-2.gif:
     21        * fast/images/resources/animated-red-green-blue-repeat-infinite.gif:
     22
    1232018-04-16  Antoine Quint  <graouts@apple.com>
    224
  • trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html

    r210951 r230712  
    1010<body>
    1111    <div>
    12         <p>Frames of a 3-frame animated image with loopCount = 1:</p>
     12        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
    1313        <div class="box" style="background-color: red;"></div>
    1414        <div class="box" style="background-color: green;"></div>
     
    1717    </div>
    1818    <div>
    19         <p>Frames of a 3-frame animated image with loopCount = 2:</p>
     19        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
    2020        <div class="box" style="background-color: red;"></div>
    2121        <div class="box" style="background-color: green;"></div>
     
    2626        <div class="box" style="background-color: blue;"></div>
    2727    </div>
     28    <div>
     29        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
     30        <div class="box" style="background-color: red;"></div>
     31        <div class="box" style="background-color: green;"></div>
     32        <div class="box" style="background-color: blue;"></div>
     33        <div class="box" style="background-color: red;"></div>
     34        <div class="box" style="background-color: green;"></div>
     35        <div class="box" style="background-color: blue;"></div>
     36        <div class="box" style="background-color: red;"></div>
     37    </div>
    2838</body>
    2939</html>
  • trunk/LayoutTests/fast/images/animated-image-loop-count.html

    r214450 r230712  
    99<body>
    1010    <div>
    11         <p>Frames of a 3-frame animated image with loopCount = 1:</p>
     11        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
    1212        <canvas id="canvas-1"></canvas>
    1313        <canvas id="canvas-2"></canvas>
     
    1616    </div>
    1717    <div>
    18         <p>Frames of a 3-frame animated image with loopCount = 2:</p>
     18        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
    1919        <canvas id="canvas-a"></canvas>
    2020        <canvas id="canvas-b"></canvas>
     
    2424        <canvas id="canvas-f"></canvas>
    2525        <canvas id="canvas-g"></canvas>
     26    </div>
     27    <div>
     28        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
     29        <canvas id="canvas-A"></canvas>
     30        <canvas id="canvas-B"></canvas>
     31        <canvas id="canvas-C"></canvas>
     32        <canvas id="canvas-D"></canvas>
     33        <canvas id="canvas-E"></canvas>
     34        <canvas id="canvas-F"></canvas>
     35        <canvas id="canvas-G"></canvas>
    2636    </div>
    2737    <script>
     
    6676            var images = [
    6777                { src: "resources/animated-red-green-blue-repeat-1.gif", canvasId: '1', frameCount: 4 },
    68                 { src: "resources/animated-red-green-blue-repeat-2.gif", canvasId: 'a', frameCount: 7 }
     78                { src: "resources/animated-red-green-blue-repeat-2.gif", canvasId: 'a', frameCount: 7 },
     79                { src: "resources/animated-red-green-blue-repeat-infinite.gif", canvasId: 'A', frameCount: 7 }
    6980            ];
    7081
  • trunk/Source/WebCore/ChangeLog

    r230711 r230712  
     12018-04-17  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Animated GIF imagery with finite looping are falling one loop short
     4        https://bugs.webkit.org/show_bug.cgi?id=183153
     5
     6        Reviewed by Simon Fraser.
     7
     8        The Netscape Looping Application Extension is a block which may be added
     9        to a GIF file to tell the viewer to loop through the entire GIF frames.
     10        This is communicated through two bytes designated for the "loopCount" in
     11        this block.
     12
     13        The entire block may not be found in the GIF, in which case the GIF is
     14        supposed to animate its entire frames only once.
     15
     16        If the block exists and loopCount = 0, this means the image has to loop
     17        through its frames indefinitely.
     18
     19        If the block exist and loopCount > 0, this should mean the image has to
     20        loop through its frames loopCount + 1 times. The extra loop seems to be
     21        the consensus among most of the GIF generators and viewers. For example,
     22        if the image designer wants the image to loop through its frames n times:
     23        -- The GIF generator (e.g. Adobe Photoshop and https://ezgif.com/maker)
     24           will write n - 1 for loopCount. However http://gifmaker.me and
     25           http://gifmaker.org write n for loopCount.
     26        -- The browser (e.g. Chrome 65.0.3325 181 and FireFox Quantum 59.0.2) will
     27           translate loopCount = n - 1 to: animate GIF once + loop n - 1, which
     28           means loop the GIF n times.
     29
     30        Because the specs are not really clear about this, we are going to consider
     31        the agreed-upon behavior among most of the web browsers the specs here.
     32
     33        * platform/graphics/cg/ImageDecoderCG.cpp:
     34        (WebCore::ImageDecoderCG::repetitionCount const):
     35        * platform/image-decoders/gif/GIFImageDecoder.cpp:
     36        (WebCore::GIFImageDecoder::repetitionCount const):
     37
    1382018-04-17  Saam Barati  <sbarati@apple.com>
    239
  • trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp

    r229400 r230712  
    246246       
    247247        // A property with value 0 means loop forever.
    248         return loopCount ? loopCount : RepetitionCountInfinite;
     248        // For loopCount > 0, the specs is not clear about it. But it looks the meaning
     249        // is: play once + loop loopCount which is equivalent to play loopCount + 1.
     250        return loopCount ? loopCount + 1 : RepetitionCountInfinite;
    249251    }
    250252   
  • trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp

    r230522 r230712  
    9696        m_repetitionCount = RepetitionCountOnce;
    9797    else if (m_reader && m_reader->loopCount() != cLoopCountNotSeen)
    98         m_repetitionCount = m_reader->loopCount();
     98        m_repetitionCount = m_reader->loopCount() > 0 ? m_reader->loopCount() + 1 : m_reader->loopCount();
    9999    return m_repetitionCount;
    100100}
Note: See TracChangeset for help on using the changeset viewer.