Diff
Modified: trunk/LayoutTests/ChangeLog (96432 => 96433)
--- trunk/LayoutTests/ChangeLog 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/LayoutTests/ChangeLog 2011-09-30 22:31:01 UTC (rev 96433)
@@ -1,3 +1,21 @@
+2011-09-30 Johnny Ding <j...@chromium.org>
+
+ 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:
+
2011-09-30 David Hyatt <hy...@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=69173
Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer.html (96432 => 96433)
--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer.html 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer.html 2011-09-30 22:31:01 UTC (rev 96433)
@@ -28,7 +28,11 @@
if (!properties) {
for (var i = 0; i != style.length; ++i) {
var name = style.item(i);
- if (name != "-webkit-dashboard-region")
+ // "-webkit-tap-highlight-color" is only available on the
+ // ports which have enabled TOUCH_EVENTS flag. We test it in
+ // layout test fast/events/touch/tap-highlight-color.html.
+ if (name != "-webkit-dashboard-region" &&
+ name != "-webkit-tap-highlight-color")
log(" " + name + ": " + style.getPropertyValue(name));
}
properties = others;
Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style.html (96432 => 96433)
--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style.html 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style.html 2011-09-30 22:31:01 UTC (rev 96433)
@@ -7,7 +7,11 @@
for (var i = 0; i != style.length; ++i) {
var name = style.item(i);
var value = style.getPropertyValue(name);
- if (name != "-webkit-dashboard-region")
+ // "-webkit-tap-highlight-color" is only available on the ports
+ // which have enabled TOUCH_EVENTS flag. We test it in layout test
+ // fast/events/touch/tap-highlight-color.html.
+ if (name != "-webkit-dashboard-region" &&
+ name != "-webkit-tap-highlight-color")
text += name + ": " + value + ";\n";
}
document.getElementById("exposed").textContent = text;
Added: trunk/LayoutTests/fast/events/touch/script-tests/tap-highlight-color.js (0 => 96433)
--- trunk/LayoutTests/fast/events/touch/script-tests/tap-highlight-color.js (rev 0)
+++ trunk/LayoutTests/fast/events/touch/script-tests/tap-highlight-color.js 2011-09-30 22:31:01 UTC (rev 96433)
@@ -0,0 +1,54 @@
+var div = document.createElement("div");
+div.id = "touchtarget";
+div.style.width = "100px";
+div.style.height = "100px";
+div.style.color = "blue";
+div.innerText = "Touch Me!";
+div.style.webkitTapHighlightColor = "rgba(11, 22, 33, 0)";
+
+function onTouchStart()
+{
+ debug("Event: touch start");
+ shouldBeEqualToString("event.targetTouches[0].target.tagName", "DIV");
+ shouldBeEqualToString("event.targetTouches[0].target.id", "touchtarget");
+ shouldBeEqualToString("div.ownerDocument.defaultView.getComputedStyle(div, null).getPropertyValue('-webkit-tap-highlight-color')", "rgba(11, 22, 33, 0)");
+ div.style.webkitTapHighlightColor = ""; // Clear the customized tap highlight color
+}
+
+function onTouchEnd()
+{
+ debug("Event: touch end");
+ // Check the default value.
+ shouldBeFalse("div.ownerDocument.defaultView.getComputedStyle(div, null).getPropertyValue('-webkit-tap-highlight-color') == 'rgba(11, 22, 33, 0)'")
+ shouldBeNonNull("div.ownerDocument.defaultView.getComputedStyle(div, null).getPropertyValue('-webkit-tap-highlight-color')");
+ // Notify the test done.
+ successfullyParsed = true;
+ isSuccessfullyParsed();
+ layoutTestController.notifyDone();
+}
+
+div.addEventListener("touchstart", onTouchStart, false);
+div.addEventListener("touchend", onTouchEnd, false);
+document.body.insertBefore(div, document.body.firstChild);
+
+function touchTargets()
+{
+ eventSender.clearTouchPoints();
+ eventSender.addTouchPoint(20, 20);
+ eventSender.touchStart();
+ eventSender.updateTouchPoint(0, 50, 50);
+ eventSender.touchMove();
+ eventSender.releaseTouchPoint(0);
+ eventSender.touchEnd();
+}
+
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+if (window.eventSender && eventSender.clearTouchPoints) {
+ description("Check tap highlight color in touch event");
+
+ touchTargets();
+} else {
+ debug("This test requires DumpRenderTree && WebKit built with ENABLE(TOUCH_EVENT).")
+}
Added: trunk/LayoutTests/fast/events/touch/tap-highlight-color-expected.txt (0 => 96433)
--- trunk/LayoutTests/fast/events/touch/tap-highlight-color-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/touch/tap-highlight-color-expected.txt 2011-09-30 22:31:01 UTC (rev 96433)
@@ -0,0 +1,17 @@
+Touch Me!
+Check tap highlight color in touch event
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Event: touch start
+PASS event.targetTouches[0].target.tagName is "DIV"
+PASS event.targetTouches[0].target.id is "touchtarget"
+PASS div.ownerDocument.defaultView.getComputedStyle(div, null).getPropertyValue('-webkit-tap-highlight-color') is "rgba(11, 22, 33, 0)"
+Event: touch end
+PASS div.ownerDocument.defaultView.getComputedStyle(div, null).getPropertyValue('-webkit-tap-highlight-color') == 'rgba(11, 22, 33, 0)' is false
+PASS div.ownerDocument.defaultView.getComputedStyle(div, null).getPropertyValue('-webkit-tap-highlight-color') is non-null.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/touch/tap-highlight-color.html (0 => 96433)
--- trunk/LayoutTests/fast/events/touch/tap-highlight-color.html (rev 0)
+++ trunk/LayoutTests/fast/events/touch/tap-highlight-color.html 2011-09-30 22:31:01 UTC (rev 96433)
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<!--
+ To test the new CSS property -webkit-tap-highlight-color which is only supported when building
+ WebKit with ENABLE(TOUCH_EVENTS), we create a new div element and add -webkit-tap-highlight-color
+ in the element, then see whether we can get the specified tap highlight color from DOM.
+ WebKit ports can use this css property to get the customized tap highlight color from the webpage
+ which is set by web developers to make sure that tap highlight color fits their websites instead
+ of using the hardcode value provided by browsers.
+-->
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/svg/css/getComputedStyle-basic.xhtml (96432 => 96433)
--- trunk/LayoutTests/svg/css/getComputedStyle-basic.xhtml 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/LayoutTests/svg/css/getComputedStyle-basic.xhtml 2011-09-30 22:31:01 UTC (rev 96433)
@@ -24,8 +24,11 @@
var name = style.item(x);
var value = style.getPropertyValue(name);
var cssValue = style.getPropertyCSSValue(name);
-
- if (name != "-webkit-dashboard-region") {
+ // "-webkit-tap-highlight-color" is only available on the ports
+ // which have enabled TOUCH_EVENTS flag. We test it in layout test
+ // fast/events/touch/tap-highlight-color.html.
+ if (name != "-webkit-dashboard-region" &&
+ name != "-webkit-tap-highlight-color") {
debugLog(elementId + ": style.getPropertyValue(" + name + ") : " + value);
debugLog(elementId + ": style.getPropertyCSSValue(" + name + ") : " + cssValue);
}
Modified: trunk/Source/WebCore/ChangeLog (96432 => 96433)
--- trunk/Source/WebCore/ChangeLog 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/ChangeLog 2011-09-30 22:31:01 UTC (rev 96433)
@@ -1,3 +1,39 @@
+2011-09-30 Johnny Ding <j...@chromium.org>
+
+ 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:
+
2011-09-30 David Hyatt <hy...@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=69173
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (96432 => 96433)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2011-09-30 22:31:01 UTC (rev 96433)
@@ -247,6 +247,9 @@
CSSPropertyWebkitPerspective,
CSSPropertyWebkitPerspectiveOrigin,
CSSPropertyWebkitRtlOrdering,
+#if ENABLE(TOUCH_EVENTS)
+ CSSPropertyWebkitTapHighlightColor,
+#endif
CSSPropertyWebkitTextCombine,
CSSPropertyWebkitTextDecorationsInEffect,
CSSPropertyWebkitTextEmphasisColor,
@@ -1797,6 +1800,10 @@
}
case CSSPropertyWebkitRtlOrdering:
return primitiveValueCache->createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
+#if ENABLE(TOUCH_EVENTS)
+ case CSSPropertyWebkitTapHighlightColor:
+ return currentColorOrValidColor(style.get(), style->tapHighlightColor());
+#endif
case CSSPropertyWebkitUserDrag:
return primitiveValueCache->createValue(style->userDrag());
case CSSPropertyWebkitUserSelect:
Modified: trunk/Source/WebCore/css/CSSParser.cpp (96432 => 96433)
--- trunk/Source/WebCore/css/CSSParser.cpp 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2011-09-30 22:31:01 UTC (rev 96433)
@@ -1934,6 +1934,18 @@
#endif
// End Apple-specific properties
+#if ENABLE(TOUCH_EVENTS)
+ case CSSPropertyWebkitTapHighlightColor:
+ if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu
+ || (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && !m_strict)) {
+ validPrimitive = true;
+ } else {
+ parsedValue = parseColor();
+ if (parsedValue)
+ m_valueList->next();
+ }
+ break;
+#endif
/* shorthand properties */
case CSSPropertyBackground: {
// Position must come before color in this array because a plain old "0" is a legal color
Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (96432 => 96433)
--- trunk/Source/WebCore/css/CSSPropertyNames.in 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in 2011-09-30 22:31:01 UTC (rev 96433)
@@ -355,4 +355,7 @@
-webkit-region-break-after
-webkit-region-break-before
-webkit-region-break-inside
+#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
+-webkit-tap-highlight-color
+#endif
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (96432 => 96433)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-09-30 22:31:01 UTC (rev 96433)
@@ -3634,6 +3634,17 @@
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(pointerEvents, PointerEvents)
return;
}
+#if ENABLE(TOUCH_EVENTS)
+ case CSSPropertyWebkitTapHighlightColor: {
+ HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor);
+ if (!primitiveValue)
+ break;
+
+ Color col = getColorFromPrimitiveValue(primitiveValue);
+ m_style->setTapHighlightColor(col);
+ return;
+ }
+#endif
case CSSPropertyWebkitColorCorrection:
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(colorSpace, ColorSpace);
return;
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (96432 => 96433)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2011-09-30 22:31:01 UTC (rev 96433)
@@ -1084,6 +1084,13 @@
return Color(255, 255, 0); // Yellow.
}
+#if ENABLE(TOUCH_EVENTS)
+Color RenderTheme::tapHighlightColor()
+{
+ return defaultTheme()->platformTapHighlightColor();
+}
+#endif
+
void RenderTheme::setCustomFocusRingColor(const Color& c)
{
customFocusRingColor() = c;
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (96432 => 96433)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2011-09-30 22:31:01 UTC (rev 96433)
@@ -149,7 +149,10 @@
static Color focusRingColor();
virtual Color platformFocusRingColor() const { return Color(0, 0, 0); }
static void setCustomFocusRingColor(const Color&);
-
+#if ENABLE(TOUCH_EVENTS)
+ static Color tapHighlightColor();
+ virtual Color platformTapHighlightColor() const { return RenderTheme::defaultTapHighlightColor; }
+#endif
virtual void platformColorsDidChange();
virtual double caretBlinkInterval() const { return 0.5; }
@@ -330,6 +333,10 @@
mutable Color m_activeListBoxSelectionForegroundColor;
mutable Color m_inactiveListBoxSelectionForegroundColor;
+#if ENABLE(TOUCH_EVENTS)
+ static const RGBA32 defaultTapHighlightColor = 0x33000000;
+#endif
+
#if USE(NEW_THEME)
Theme* m_theme; // The platform-specific theme.
#endif
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (96432 => 96433)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2011-09-30 22:31:01 UTC (rev 96433)
@@ -34,6 +34,9 @@
#include "ScaleTransformOperation.h"
#include "ShadowData.h"
#include "StyleImage.h"
+#if ENABLE(TOUCH_EVENTS)
+#include "RenderTheme.h"
+#endif
#include <wtf/StdLibExtras.h>
#include <algorithm>
@@ -1511,6 +1514,13 @@
return TextEmphasisMarkSesame;
}
+#if ENABLE(TOUCH_EVENTS)
+Color RenderStyle::initialTapHighlightColor()
+{
+ return RenderTheme::tapHighlightColor();
+}
+#endif
+
void RenderStyle::getImageOutsets(const NinePieceImage& image, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const
{
top = NinePieceImage::computeOutset(image.outset().top(), borderTopWidth());
@@ -1530,5 +1540,5 @@
top = NinePieceImage::computeOutset(image.outset().top(), borderTopWidth());
bottom = NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth());
}
-
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (96432 => 96433)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-09-30 22:31:01 UTC (rev 96433)
@@ -836,6 +836,9 @@
LineBoxContain lineBoxContain() const { return rareInheritedData->m_lineBoxContain; }
const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; }
+#if ENABLE(TOUCH_EVENTS)
+ Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
+#endif
bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
@@ -1217,6 +1220,9 @@
void setLineBoxContain(LineBoxContain c) { SET_VAR(rareInheritedData, m_lineBoxContain, c); }
void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
+#if ENABLE(TOUCH_EVENTS)
+ void setTapHighlightColor(const Color& c) { SET_VAR(rareInheritedData, tapHighlightColor, c); }
+#endif
bool setTextSizeAdjust(bool);
void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
@@ -1466,6 +1472,9 @@
static LineClampValue initialLineClamp() { return LineClampValue(); }
static bool initialTextSizeAdjust() { return true; }
static ETextSecurity initialTextSecurity() { return TSNONE; }
+#if ENABLE(TOUCH_EVENTS)
+ static Color initialTapHighlightColor();
+#endif
#if ENABLE(DASHBOARD_SUPPORT)
static const Vector<StyleDashboardRegion>& initialDashboardRegions();
static const Vector<StyleDashboardRegion>& noneDashboardRegions();
Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp (96432 => 96433)
--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp 2011-09-30 22:31:01 UTC (rev 96433)
@@ -56,6 +56,9 @@
, hyphenationLimitBefore(-1)
, hyphenationLimitAfter(-1)
, hyphenationLimitLines(-1)
+#if ENABLE(TOUCH_EVENTS)
+ , tapHighlightColor(RenderStyle::initialTapHighlightColor())
+#endif
{
}
@@ -95,6 +98,9 @@
, hyphenationLimitLines(o.hyphenationLimitLines)
, locale(o.locale)
, textEmphasisCustomMark(o.textEmphasisCustomMark)
+#if ENABLE(TOUCH_EVENTS)
+ , tapHighlightColor(o.tapHighlightColor)
+#endif
{
}
@@ -117,6 +123,9 @@
&& textStrokeWidth == o.textStrokeWidth
&& textFillColor == o.textFillColor
&& textEmphasisColor == o.textEmphasisColor
+#if ENABLE(TOUCH_EVENTS)
+ && tapHighlightColor == o.tapHighlightColor
+#endif
&& shadowDataEquivalent(o)
&& highlight == o.highlight
&& cursorDataEquivalent(cursorData.get(), o.cursorData.get())
Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (96432 => 96433)
--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2011-09-30 22:23:33 UTC (rev 96432)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2011-09-30 22:31:01 UTC (rev 96433)
@@ -98,6 +98,9 @@
AtomicString textEmphasisCustomMark;
RefPtr<QuotesData> quotes;
+#if ENABLE(TOUCH_EVENTS)
+ Color tapHighlightColor;
+#endif
private:
StyleRareInheritedData();