Changeset 96433 in webkit


Ignore:
Timestamp:
Sep 30, 2011 3:31:01 PM (13 years ago)
Author:
jnd@chromium.org
Message:

Source/WebCore: Support -webkit-tap-highlight-color when enabling touch events support.
https://bugs.webkit.org/show_bug.cgi?id=48544

Reviewed by Kenneth Rohde Christiansen.

Original code from the iOS WebCore code dump, extracted and modified by tijiang@rim and jnd@chromium.
Supports the new CSS property -webkit-tap-highlight-color on platforms which support touch events.
Platform can override WebCore::RenderTheme::platformTapHighlightColor to use its own platform
specific default tap highlight color. Otherwise RenderTheme::defaultTapHighlightColor will be
used as default tap highlight color.

Test: fast/events/touch/tap-highlight-color.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):

  • css/CSSPropertyNames.in:
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty):

  • rendering/RenderTheme.cpp:

(WebCore::RenderTheme::tapHighlightColor):

  • rendering/RenderTheme.h:

(WebCore::RenderTheme::platformTapHighlightColor):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::initialTapHighlightColor):

  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::tapHighlightColor):
(WebCore::InheritedFlags::setTapHighlightColor):

  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):

  • rendering/style/StyleRareInheritedData.h:

LayoutTests: Support -webkit-tap-highlight-color in WebCore when enabling touch events support.
https://bugs.webkit.org/show_bug.cgi?id=48544.

Reviewed by Kenneth Rohde Christiansen.

Add a layout test to get customized tap highlight color set by page author.

  • fast/css/getComputedStyle/computed-style-without-renderer.html:
  • fast/css/getComputedStyle/computed-style.html:
  • fast/events/touch/script-tests/tap-highlight-color.js: Added.

(onTouchStart):
(touchTargets):

  • fast/events/touch/tap-highlight-color-expected.txt: Added.
  • fast/events/touch/tap-highlight-color.html: Added.
  • svg/css/getComputedStyle-basic.xhtml:
Location:
trunk
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96431 r96433  
     12011-09-30  Johnny Ding  <jnd@chromium.org>
     2
     3        Support -webkit-tap-highlight-color in WebCore when enabling touch events support.
     4        https://bugs.webkit.org/show_bug.cgi?id=48544.
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Add a layout test to get customized tap highlight color set by page author.
     9
     10        * fast/css/getComputedStyle/computed-style-without-renderer.html:
     11        * fast/css/getComputedStyle/computed-style.html:
     12        * fast/events/touch/script-tests/tap-highlight-color.js: Added.
     13        (onTouchStart):
     14        (touchTargets):
     15        * fast/events/touch/tap-highlight-color-expected.txt: Added.
     16        * fast/events/touch/tap-highlight-color.html: Added.
     17        * svg/css/getComputedStyle-basic.xhtml:
     18
    1192011-09-30  David Hyatt  <hyatt@apple.com>
    220
  • trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer.html

    r69220 r96433  
    2929                for (var i = 0; i != style.length; ++i) {
    3030                    var name = style.item(i);
    31                     if (name != "-webkit-dashboard-region")
     31                    // "-webkit-tap-highlight-color" is only available on the
     32                    // ports which have enabled TOUCH_EVENTS flag. We test it in
     33                    // layout test fast/events/touch/tap-highlight-color.html.
     34                    if (name != "-webkit-dashboard-region" &&
     35                        name != "-webkit-tap-highlight-color")
    3236                        log("    " + name + ": " + style.getPropertyValue(name));
    3337                }
  • trunk/LayoutTests/fast/css/getComputedStyle/computed-style.html

    r69220 r96433  
    88        var name = style.item(i);
    99        var value = style.getPropertyValue(name);
    10         if (name != "-webkit-dashboard-region")
     10        // "-webkit-tap-highlight-color" is only available on the ports
     11        // which have enabled TOUCH_EVENTS flag. We test it in layout test
     12        // fast/events/touch/tap-highlight-color.html.
     13        if (name != "-webkit-dashboard-region" &&
     14            name != "-webkit-tap-highlight-color")
    1115            text += name + ": " + value + ";\n";
    1216    }
  • trunk/LayoutTests/svg/css/getComputedStyle-basic.xhtml

    r69220 r96433  
    2525          var value = style.getPropertyValue(name);
    2626          var cssValue = style.getPropertyCSSValue(name);
    27  
    28           if (name != "-webkit-dashboard-region") {
     27          // "-webkit-tap-highlight-color" is only available on the ports
     28          // which have enabled TOUCH_EVENTS flag. We test it in layout test
     29          // fast/events/touch/tap-highlight-color.html.
     30          if (name != "-webkit-dashboard-region" &&
     31              name != "-webkit-tap-highlight-color") {
    2932            debugLog(elementId + ": style.getPropertyValue(" + name + ") : " + value);
    3033            debugLog(elementId + ": style.getPropertyCSSValue(" + name + ") : " + cssValue);
  • trunk/Source/WebCore/ChangeLog

    r96431 r96433  
     12011-09-30  Johnny Ding  <jnd@chromium.org>
     2
     3        Support -webkit-tap-highlight-color when enabling touch events support.
     4        https://bugs.webkit.org/show_bug.cgi?id=48544
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Original code from the iOS WebCore code dump, extracted and modified by tijiang@rim and jnd@chromium.
     9        Supports the new CSS property -webkit-tap-highlight-color on platforms which support touch events.
     10        Platform can override WebCore::RenderTheme::platformTapHighlightColor to use its own platform
     11        specific default tap highlight color. Otherwise RenderTheme::defaultTapHighlightColor will be
     12        used as default tap highlight color.
     13
     14        Test: fast/events/touch/tap-highlight-color.html
     15
     16        * css/CSSComputedStyleDeclaration.cpp:
     17        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     18        * css/CSSParser.cpp:
     19        (WebCore::CSSParser::parseValue):
     20        * css/CSSPropertyNames.in:
     21        * css/CSSStyleSelector.cpp:
     22        (WebCore::CSSStyleSelector::applyProperty):
     23        * rendering/RenderTheme.cpp:
     24        (WebCore::RenderTheme::tapHighlightColor):
     25        * rendering/RenderTheme.h:
     26        (WebCore::RenderTheme::platformTapHighlightColor):
     27        * rendering/style/RenderStyle.cpp:
     28        (WebCore::RenderStyle::initialTapHighlightColor):
     29        * rendering/style/RenderStyle.h:
     30        (WebCore::InheritedFlags::tapHighlightColor):
     31        (WebCore::InheritedFlags::setTapHighlightColor):
     32        * rendering/style/StyleRareInheritedData.cpp:
     33        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
     34        (WebCore::StyleRareInheritedData::operator==):
     35        * rendering/style/StyleRareInheritedData.h:
     36
    1372011-09-30  David Hyatt  <hyatt@apple.com>
    238
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r95888 r96433  
    248248    CSSPropertyWebkitPerspectiveOrigin,
    249249    CSSPropertyWebkitRtlOrdering,
     250#if ENABLE(TOUCH_EVENTS)
     251    CSSPropertyWebkitTapHighlightColor,
     252#endif
    250253    CSSPropertyWebkitTextCombine,
    251254    CSSPropertyWebkitTextDecorationsInEffect,
     
    17981801        case CSSPropertyWebkitRtlOrdering:
    17991802            return primitiveValueCache->createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
     1803#if ENABLE(TOUCH_EVENTS)
     1804        case CSSPropertyWebkitTapHighlightColor:
     1805            return currentColorOrValidColor(style.get(), style->tapHighlightColor());
     1806#endif           
    18001807        case CSSPropertyWebkitUserDrag:
    18011808            return primitiveValueCache->createValue(style->userDrag());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r96276 r96433  
    19351935    // End Apple-specific properties
    19361936
     1937#if ENABLE(TOUCH_EVENTS)
     1938    case CSSPropertyWebkitTapHighlightColor:
     1939        if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu
     1940            || (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && !m_strict)) {
     1941             validPrimitive = true;
     1942        } else {
     1943            parsedValue = parseColor();
     1944            if (parsedValue)
     1945                m_valueList->next();
     1946        }
     1947        break;
     1948#endif
    19371949        /* shorthand properties */
    19381950    case CSSPropertyBackground: {
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r95888 r96433  
    356356-webkit-region-break-before
    357357-webkit-region-break-inside
     358#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
     359-webkit-tap-highlight-color
     360#endif
    358361
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r96393 r96433  
    36353635        return;
    36363636    }
     3637#if ENABLE(TOUCH_EVENTS)
     3638    case CSSPropertyWebkitTapHighlightColor: {
     3639        HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor);
     3640        if (!primitiveValue)
     3641            break;
     3642
     3643        Color col = getColorFromPrimitiveValue(primitiveValue);
     3644        m_style->setTapHighlightColor(col);
     3645        return;
     3646    }
     3647#endif
    36373648    case CSSPropertyWebkitColorCorrection:
    36383649        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(colorSpace, ColorSpace);
  • trunk/Source/WebCore/rendering/RenderTheme.cpp

    r94149 r96433  
    10851085}
    10861086
     1087#if ENABLE(TOUCH_EVENTS)
     1088Color RenderTheme::tapHighlightColor()
     1089{
     1090    return defaultTheme()->platformTapHighlightColor();
     1091}
     1092#endif
     1093
    10871094void RenderTheme::setCustomFocusRingColor(const Color& c)
    10881095{
  • trunk/Source/WebCore/rendering/RenderTheme.h

    r90048 r96433  
    150150    virtual Color platformFocusRingColor() const { return Color(0, 0, 0); }
    151151    static void setCustomFocusRingColor(const Color&);
    152 
     152#if ENABLE(TOUCH_EVENTS)
     153    static Color tapHighlightColor();
     154    virtual Color platformTapHighlightColor() const { return RenderTheme::defaultTapHighlightColor; }
     155#endif
    153156    virtual void platformColorsDidChange();
    154157
     
    331334    mutable Color m_inactiveListBoxSelectionForegroundColor;
    332335
     336#if ENABLE(TOUCH_EVENTS)
     337    static const RGBA32 defaultTapHighlightColor = 0x33000000;
     338#endif
     339
    333340#if USE(NEW_THEME)
    334341    Theme* m_theme; // The platform-specific theme.
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r96393 r96433  
    3535#include "ShadowData.h"
    3636#include "StyleImage.h"
     37#if ENABLE(TOUCH_EVENTS)
     38#include "RenderTheme.h"
     39#endif
    3740#include <wtf/StdLibExtras.h>
    3841#include <algorithm>
     
    15121515}
    15131516
     1517#if ENABLE(TOUCH_EVENTS)
     1518Color RenderStyle::initialTapHighlightColor()
     1519{
     1520    return RenderTheme::tapHighlightColor();
     1521}
     1522#endif
     1523
    15141524void RenderStyle::getImageOutsets(const NinePieceImage& image, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const
    15151525{
     
    15311541    bottom = NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth());
    15321542}
    1533    
     1543
    15341544} // namespace WebCore
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r96393 r96433  
    837837    LineBoxContain lineBoxContain() const { return rareInheritedData->m_lineBoxContain; }
    838838    const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; }
     839#if ENABLE(TOUCH_EVENTS)
     840    Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
     841#endif
    839842    bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
    840843    ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
     
    12181221    void setLineBoxContain(LineBoxContain c) { SET_VAR(rareInheritedData, m_lineBoxContain, c); }
    12191222    void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
     1223#if ENABLE(TOUCH_EVENTS)
     1224    void setTapHighlightColor(const Color& c) { SET_VAR(rareInheritedData, tapHighlightColor, c); }
     1225#endif
    12201226    bool setTextSizeAdjust(bool);
    12211227    void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
     
    14671473    static bool initialTextSizeAdjust() { return true; }
    14681474    static ETextSecurity initialTextSecurity() { return TSNONE; }
     1475#if ENABLE(TOUCH_EVENTS)
     1476    static Color initialTapHighlightColor();
     1477#endif
    14691478#if ENABLE(DASHBOARD_SUPPORT)
    14701479    static const Vector<StyleDashboardRegion>& initialDashboardRegions();
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r94710 r96433  
    5757    , hyphenationLimitAfter(-1)
    5858    , hyphenationLimitLines(-1)
     59#if ENABLE(TOUCH_EVENTS)
     60    , tapHighlightColor(RenderStyle::initialTapHighlightColor())
     61#endif   
    5962{
    6063}
     
    9699    , locale(o.locale)
    97100    , textEmphasisCustomMark(o.textEmphasisCustomMark)
     101#if ENABLE(TOUCH_EVENTS)
     102    , tapHighlightColor(o.tapHighlightColor)
     103#endif
    98104{
    99105}
     
    118124        && textFillColor == o.textFillColor
    119125        && textEmphasisColor == o.textEmphasisColor
     126#if ENABLE(TOUCH_EVENTS)
     127        && tapHighlightColor == o.tapHighlightColor
     128#endif
    120129        && shadowDataEquivalent(o)
    121130        && highlight == o.highlight
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r94710 r96433  
    9999    AtomicString textEmphasisCustomMark;
    100100    RefPtr<QuotesData> quotes;
     101#if ENABLE(TOUCH_EVENTS)
     102    Color tapHighlightColor;
     103#endif
    101104
    102105private:
Note: See TracChangeset for help on using the changeset viewer.