Ignore:
Timestamp:
Oct 2, 2014, 11:35:30 AM (11 years ago)
Author:
[email protected]
Message:

Clean up loops in CSSGradientValue.cpp
https://bugs.webkit.org/show_bug.cgi?id=137332

Reviewed by Andreas Kling.

This patch cleans up a couple of for loops by using C++11 syntax and
fixes some grammar in a comment.

No new tests, no behavior change.

  • css/CSSGradientValue.cpp:

(WebCore::CSSGradientValue::gradientWithStylesResolved): Move for loops to C++11.
(WebCore::CSSGradientValue::addStops): Update grammar in comment for gradient midpoints.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r174191 r174222  
    108108{
    109109    bool derived = false;
    110     for (unsigned i = 0; i < m_stops.size(); i++) {
    111         if (!m_stops[i].isMidpoint && styleResolver->colorFromPrimitiveValueIsDerivedFromElement(m_stops[i].m_color.get())) {
    112             m_stops[i].m_colorIsDerivedFromElement = true;
     110    for (auto& stop : m_stops) {
     111        if (!stop.isMidpoint && styleResolver->colorFromPrimitiveValueIsDerivedFromElement(stop.m_color.get())) {
     112            stop.m_colorIsDerivedFromElement = true;
    113113            derived = true;
    114114            break;
     
    128128    }
    129129
    130     for (unsigned i = 0; i < result->m_stops.size(); i++) {
    131         if (!result->m_stops[i].isMidpoint)
    132             result->m_stops[i].m_resolvedColor = styleResolver->colorFromPrimitiveValue(result->m_stops[i].m_color.get());
     130    for (auto& stop : result->m_stops) {
     131        if (!stop.isMidpoint)
     132            stop.m_resolvedColor = styleResolver->colorFromPrimitiveValue(stop.m_color.get());
    133133    }
    134134
     
    277277    // Stops on the side with the most stops start midway because the curve approximates
    278278    // a line in that region. We then add 5 more color stops on that side to minimize the change
    279     // how the luminance changes at each of the colorstops. We don't have to add as many on the other side
    280     // since it becomes small which increases the differentation of luminance which hides the colorstops.
    281     // Even with 4 extra colorstops, it *is* possible to discern the steps when the gradient is large and has
     279    // how the luminance changes at each of the color stops. We don't have to add as many on the other side
     280    // since it becomes small which increases the differentation of luminance which hides the color stops.
     281    // Even with 4 extra color stops, it *is* possible to discern the steps when the gradient is large and has
    282282    // large luminance differences between midpoint and color stop. If this becomes an issue, we can consider
    283283    // making this algorithm a bit smarter.
Note: See TracChangeset for help on using the changeset viewer.