diff options
author | Cary Clark <cary@android.com> | 2010-07-28 17:11:14 -0400 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2010-07-30 12:16:34 -0400 |
commit | 0ed6485271097ecf1b4cf4e790f9cfdbb57d921c (patch) | |
tree | 3b1c843d882ebb2883bd16c215753743e1ce7749 | |
parent | eaa543700296fbdd6583bd8dc68108e6a734d7d1 (diff) | |
download | external_webkit-0ed6485271097ecf1b4cf4e790f9cfdbb57d921c.zip external_webkit-0ed6485271097ecf1b4cf4e790f9cfdbb57d921c.tar.gz external_webkit-0ed6485271097ecf1b4cf4e790f9cfdbb57d921c.tar.bz2 |
Add CSS cursor ring definitions
This allows web pages to have fine-grain control over the appearance
of the rings drawn around nodes.
Generated links (email, addresses, phone numbers) are no longer
given unique colors. To preserve this feature, a separate change
could add an HTML extension similar to vlink to provide the cursor
ring defintions for theses links. The mechanism implemented below
isn't appropriate since these links don't necessarily correspond to
single DOM nodes or other DOM elements.
------------
CSS examples
------------
The CSS to specify the ring looks like:
-webkit-ring-fill-color:rgba(0,0,255,0.4);
-webkit-ring-inner-width:2 px;
-webkit-ring-outer-width:3.5 px;
-webkit-ring-outset: 8 px;
-webkit-ring-pressed-inner-color:rgba(0,0,255,0.8);
-webkit-ring-pressed-outer-color:rgba(0,0,127,0.3);
-webkit-ring-radius: 10 px;
-webkit-ring-selected-inner-color:rgba(63,63,255,0.8);
-webkit-ring-selected-outer-color:rgba(63,63,127,0.3);
and may be alternately defined with a property shortcut:
-webkit-ring:rgba(255,0,0,0.4) 5px 7px
rgba(255,0,0,0.8) rgba(127,0,0,0.3) 20px
rgba(255,63,63,0.8) rgba(127,63,63,0.3);
--------------------
Property definitions
--------------------
A vertical cross-section of the ring corresponds to these
parameters as shown:
______
R / ___O_ R = corner radius
/ / __I_ o I = inner ring
/ / / _O_ ^ O = outer ring
| | | / F | F = fill
|O|I|O| L o = outset
| | | \_F_ | L = original link
\ \ \__O_ V
\ \___I_ o
R \____O_
The fill color specifies what to draw inside the ring
when the link is followed. The fill area consists of the
original link area the outset.
The inner and outer widths specify the stoke width of the inner
and outer rings, respectively. The widths may be specified in
fractional pixels. The implementation captures 4 bits of the
fraction.
The outset specifies the distance from the edge of the original
link to the rings' center. Both rings are drawn at the same center
location.
The radius specifies the curvature of the corners at the center
of the rings.
-------------
Data lifetime
-------------
The selected colors specify the colors of the inner and outer
rings when the trackball or D-pad hovers over the link. The
pressed colors specify the colors of the rings when the
trackball center is pressed or the link is tapped.
The CSS data is recorded in the RenderStyle when the DOM
is parsed. The widths are scaled up by 16 to preserve the fraction.
When the nav cache is built, the CSS style information is
recorded in the CachedColor class. Only unique style sets
are recorded; many CachedNode instances can share the same
CachedColor instance.
When the cursor ring is drawn, the CachedColor is
retrieved by getting the index from the CachedNode, and
looking up the entry in the CachedFrame. The widths are
scaled down by 16 since Lengths are stored by the webkit as
integers.
----------
File Edits
----------
WebCore/Android.derived.mk
- Build the CSS data property tables by concatentating
Android specific data and optionally SVG data.
WebCore/config.h
- Add switch for these rings. This switch is meant
as a convenience for finding the code in WebKit
that was added to enable this feature. Since the
old code in DrawCursor has been removed, it does
not revert to the old behavior if the switch is
turned off.
WebCore/css/AndroidCSSPropertyNames.in
- The new ring properties, plus an old one we
added before.
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSMutableStyleDeclaration.cpp
WebCore/css/CSSParser.cpp
WebCore/css/CSSStyleSelector.cpp
- I can guess what these functions are for as
well as anyone, but I really don't know. Do
I need all of them? Do I need to modify
Mutable at all?
WebCore/css/CSSPropertyNames.in
- Moved Android addition to AndroidCSSPropertyNames.in
WebCore/platform/graphics/Color.h
- Added initial color values here.
WebCore/platform/graphics/android/android_graphics.*
- This draws the cursor ring. The code that draws
'synthetic' links has been discarded.
WebCore/rendering/style/RenderStyle.h
- Functions to get, set, and initialize the style
data.
WebCore/rendering/style/StyleRareInheritedData.*
- The storage for the style data and an equivalence
function.
WebKit/Android.mk
- Added CachedColor to the build.
WebKit/android/nav/CacheBuilder.cpp
- Record the color from the DOM into the cache.
WebKit/android/nav/CachedColor.*
- Store the cached color info.
WebKit/android/nav/CachedFrame.*
- Where the array of colors is stored.
WebKit/android/nav/CachedNode.*
- Where the index to the colors is stored.
Change-Id: Ia3a931f41d6545e47678e245aafe7c84d4658f94
http://b/2603197
22 files changed, 583 insertions, 41 deletions
diff --git a/WebCore/Android.derived.mk b/WebCore/Android.derived.mk index a5820a7..1b0b46f 100644 --- a/WebCore/Android.derived.mk +++ b/WebCore/Android.derived.mk @@ -27,13 +27,15 @@ GEN := $(intermediates)/css/CSSPropertyNames.h $(GEN): SCRIPT := $(LOCAL_PATH)/css/makeprop.pl -$(GEN): $(intermediates)/%.h : $(LOCAL_PATH)/%.in $(LOCAL_PATH)/css/SVGCSSPropertyNames.in +ifeq ($(ENABLE_SVG),true) +$(GEN): $(intermediates)/%.h : $(LOCAL_PATH)/%.in $(LOCAL_PATH)/css/SVGCSSPropertyNames.in $(LOCAL_PATH)/css/AndroidCSSPropertyNames.in +else +$(GEN): $(intermediates)/%.h : $(LOCAL_PATH)/%.in $(LOCAL_PATH)/css/AndroidCSSPropertyNames.in +endif @echo "Generating CSSPropertyNames.h <= CSSPropertyNames.in" @mkdir -p $(dir $@) @cat $< > $(dir $@)/$(notdir $<) -ifeq ($(ENABLE_SVG),true) @cat $^ > $(@:%.h=%.in) -endif @cp -f $(SCRIPT) $(dir $@) @cd $(dir $@) ; perl ./$(notdir $(SCRIPT)) LOCAL_GENERATED_SOURCES += $(GEN) diff --git a/WebCore/config.h b/WebCore/config.h index 5d5c6c1..d912556 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -157,6 +157,7 @@ #define ANDROID_LISTBOX_USES_MENU_LIST #define ANDROID_MULTIPLE_WINDOWS +#define ANDROID_CSS_RING #define ANDROID_CSS_TAP_HIGHLIGHT_COLOR #define ANDROID_BLOCK_NETWORK_IMAGE diff --git a/WebCore/css/AndroidCSSPropertyNames.in b/WebCore/css/AndroidCSSPropertyNames.in new file mode 100644 index 0000000..ef67d6b --- /dev/null +++ b/WebCore/css/AndroidCSSPropertyNames.in @@ -0,0 +1,34 @@ +# Copyright 2010, The Android Open Source Project +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +-webkit-ring +-webkit-ring-fill-color +-webkit-ring-inner-width +-webkit-ring-outer-width +-webkit-ring-outset +-webkit-ring-pressed-inner-color +-webkit-ring-pressed-outer-color +-webkit-ring-radius +-webkit-ring-selected-inner-color +-webkit-ring-selected-outer-color +-webkit-tap-highlight-color diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp index 44ff1fc..0b05a71 100644 --- a/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -271,6 +271,18 @@ static const int computedProperties[] = { CSSPropertyWebkitSvgShadow, CSSPropertyVectorEffect #endif +#ifdef ANDROID_CSS_RING + , + CSSPropertyWebkitRingFillColor, + CSSPropertyWebkitRingInnerWidth, + CSSPropertyWebkitRingOuterWidth, + CSSPropertyWebkitRingOutset, + CSSPropertyWebkitRingPressedInnerColor, + CSSPropertyWebkitRingPressedOuterColor, + CSSPropertyWebkitRingRadius, + CSSPropertyWebkitRingSelectedInnerColor, + CSSPropertyWebkitRingSelectedOuterColor +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR , CSSPropertyWebkitTapHighlightColor @@ -1536,6 +1548,29 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper case CSSPropertyWebkitTransition: case CSSPropertyWebkitVariableDeclarationBlock: break; +#ifdef ANDROID_CSS_RING + case CSSPropertyWebkitRing: + // shorthand property currently not supported see bug 13658 + break; + case CSSPropertyWebkitRingFillColor: + return CSSPrimitiveValue::createColor(style->ringFillColor().rgb()); + case CSSPropertyWebkitRingInnerWidth: + return CSSPrimitiveValue::create(style->ringInnerWidth()); + case CSSPropertyWebkitRingOuterWidth: + return CSSPrimitiveValue::create(style->ringOuterWidth()); + case CSSPropertyWebkitRingOutset: + return CSSPrimitiveValue::create(style->ringOutset()); + case CSSPropertyWebkitRingPressedInnerColor: + return CSSPrimitiveValue::createColor(style->ringPressedInnerColor().rgb()); + case CSSPropertyWebkitRingPressedOuterColor: + return CSSPrimitiveValue::createColor(style->ringPressedOuterColor().rgb()); + case CSSPropertyWebkitRingRadius: + return CSSPrimitiveValue::create(style->ringRadius()); + case CSSPropertyWebkitRingSelectedInnerColor: + return CSSPrimitiveValue::createColor(style->ringSelectedInnerColor().rgb()); + case CSSPropertyWebkitRingSelectedOuterColor: + return CSSPrimitiveValue::createColor(style->ringSelectedOuterColor().rgb()); +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR case CSSPropertyWebkitTapHighlightColor: return CSSPrimitiveValue::createColor(style->tapHighlightColor().rgb()); diff --git a/WebCore/css/CSSMutableStyleDeclaration.cpp b/WebCore/css/CSSMutableStyleDeclaration.cpp index 8d37a2e..e3fed35 100644 --- a/WebCore/css/CSSMutableStyleDeclaration.cpp +++ b/WebCore/css/CSSMutableStyleDeclaration.cpp @@ -258,6 +258,20 @@ String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const return value->cssText(); } #endif +#ifdef ANDROID_CSS_RING + case CSSPropertyWebkitRing: { + const int properties[9] = { CSSPropertyWebkitRingFillColor, + CSSPropertyWebkitRingInnerWidth, + CSSPropertyWebkitRingOuterWidth, + CSSPropertyWebkitRingOutset, + CSSPropertyWebkitRingPressedInnerColor, + CSSPropertyWebkitRingPressedOuterColor, + CSSPropertyWebkitRingRadius, + CSSPropertyWebkitRingSelectedInnerColor, + CSSPropertyWebkitRingSelectedOuterColor }; + return getLayeredShorthandValue(properties, 9); + } +#endif } return String(); } diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp index 6bf7751..0cc935f 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -1811,6 +1811,36 @@ bool CSSParser::parseValue(int propId, bool important) break; #endif +#ifdef ANDROID_CSS_RING + case CSSPropertyWebkitRing: + { + const int properties[9] = { CSSPropertyWebkitRingFillColor, + CSSPropertyWebkitRingInnerWidth, + CSSPropertyWebkitRingOuterWidth, + CSSPropertyWebkitRingOutset, + CSSPropertyWebkitRingPressedInnerColor, + CSSPropertyWebkitRingPressedOuterColor, + CSSPropertyWebkitRingRadius, + CSSPropertyWebkitRingSelectedInnerColor, + CSSPropertyWebkitRingSelectedOuterColor }; + return parseShorthand(propId, properties, 9, important); + } + case CSSPropertyWebkitRingFillColor: + case CSSPropertyWebkitRingPressedInnerColor: + case CSSPropertyWebkitRingPressedOuterColor: + case CSSPropertyWebkitRingSelectedInnerColor: + case CSSPropertyWebkitRingSelectedOuterColor: + parsedValue = parseColor(); + if (parsedValue) + m_valueList->next(); + break; + case CSSPropertyWebkitRingInnerWidth: + case CSSPropertyWebkitRingOuterWidth: + case CSSPropertyWebkitRingOutset: + case CSSPropertyWebkitRingRadius: + validPrimitive = validUnit(value, FLength | FNonNeg, m_strict); + break; +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR case CSSPropertyWebkitTapHighlightColor: parsedValue = parseColor(); diff --git a/WebCore/css/CSSPropertyNames.in b/WebCore/css/CSSPropertyNames.in index 44216e0..ac85887 100644 --- a/WebCore/css/CSSPropertyNames.in +++ b/WebCore/css/CSSPropertyNames.in @@ -254,9 +254,6 @@ z-index -webkit-perspective-origin-x -webkit-perspective-origin-y -webkit-rtl-ordering -# ANDROID_CSS_TAP_HIGHLIGHT_COLOR: added CSS property (also in iPhone) --webkit-tap-highlight-color -# end ANDROID_CSS_TAP_HIGHLIGHT_COLOR -webkit-text-decorations-in-effect -webkit-text-fill-color -webkit-text-security diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp index 516e0e2..354c539 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -5536,6 +5536,132 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value) return; #endif +#ifdef ANDROID_CSS_RING + case CSSPropertyWebkitRing: + if (valueType != CSSValue::CSS_INHERIT || !m_parentNode) return; + m_style->setRingFillColor(m_parentStyle->ringFillColor()); + m_style->setRingInnerWidth(m_parentStyle->ringInnerWidth()); + m_style->setRingOuterWidth(m_parentStyle->ringOuterWidth()); + m_style->setRingOutset(m_parentStyle->ringOutset()); + m_style->setRingPressedInnerColor(m_parentStyle->ringPressedInnerColor()); + m_style->setRingPressedOuterColor(m_parentStyle->ringPressedOuterColor()); + m_style->setRingRadius(m_parentStyle->ringRadius()); + m_style->setRingSelectedInnerColor(m_parentStyle->ringSelectedInnerColor()); + m_style->setRingSelectedOuterColor(m_parentStyle->ringSelectedOuterColor()); + return; + case CSSPropertyWebkitRingFillColor: { + HANDLE_INHERIT_AND_INITIAL(ringFillColor, RingFillColor); + if (!primitiveValue) + break; + Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite(); + m_style->setRingFillColor(col); + return; + } + case CSSPropertyWebkitRingInnerWidth: { + HANDLE_INHERIT_AND_INITIAL(ringInnerWidth, RingInnerWidth) + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length l; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) { + // width can be specified with fractional px + // scale by 16 here (and unscale in android_graphics) to keep + // 4 bits of fraction + ExceptionCode ec; + primitiveValue->setFloatValue(primitiveValue->primitiveType(), + primitiveValue->getFloatValue() * 16, ec); + l = Length(primitiveValue->computeLengthIntForLength(style(), + m_rootElementStyle, zoomFactor), Fixed); + } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->getDoubleValue(), Percent); + else + return; + m_style->setRingInnerWidth(l); + return; + } + case CSSPropertyWebkitRingOuterWidth: { + HANDLE_INHERIT_AND_INITIAL(ringOuterWidth, RingOuterWidth) + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length l; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) { + // width can be specified with fractional px + // scale by 16 here (and unscale in android_graphics) to keep + // 4 bits of fraction + ExceptionCode ec; + primitiveValue->setFloatValue(primitiveValue->primitiveType(), + primitiveValue->getFloatValue() * 16, ec); + l = Length(primitiveValue->computeLengthIntForLength(style(), + m_rootElementStyle, zoomFactor), Fixed); + } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->getDoubleValue(), Percent); + else + return; + m_style->setRingOuterWidth(l); + return; + } + case CSSPropertyWebkitRingOutset: { + HANDLE_INHERIT_AND_INITIAL(ringOutset, RingOutset) + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length l; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) + l = Length(primitiveValue->computeLengthIntForLength(style(), + m_rootElementStyle, zoomFactor), Fixed); + else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->getDoubleValue(), Percent); + else + return; + m_style->setRingOutset(l); + return; + } + case CSSPropertyWebkitRingPressedInnerColor: { + HANDLE_INHERIT_AND_INITIAL(ringPressedInnerColor, RingPressedInnerColor); + if (!primitiveValue) + break; + Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite(); + m_style->setRingPressedInnerColor(col); + return; + } + case CSSPropertyWebkitRingPressedOuterColor: { + HANDLE_INHERIT_AND_INITIAL(ringPressedOuterColor, RingPressedOuterColor); + if (!primitiveValue) + break; + Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite(); + m_style->setRingPressedOuterColor(col); + return; + } + case CSSPropertyWebkitRingRadius: { + HANDLE_INHERIT_AND_INITIAL(ringRadius, RingRadius) + CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); + Length l; + int type = primitiveValue->primitiveType(); + if (CSSPrimitiveValue::isUnitTypeLength(type)) + l = Length(primitiveValue->computeLengthIntForLength(style(), + m_rootElementStyle, zoomFactor), Fixed); + else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) + l = Length(primitiveValue->getDoubleValue(), Percent); + else + return; + m_style->setRingRadius(l); + return; + } + case CSSPropertyWebkitRingSelectedInnerColor: { + HANDLE_INHERIT_AND_INITIAL(ringSelectedInnerColor, RingSelectedInnerColor); + if (!primitiveValue) + break; + Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite(); + m_style->setRingSelectedInnerColor(col); + return; + } + case CSSPropertyWebkitRingSelectedOuterColor: { + HANDLE_INHERIT_AND_INITIAL(ringSelectedOuterColor, RingSelectedOuterColor); + if (!primitiveValue) + break; + Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite(); + m_style->setRingSelectedOuterColor(col); + return; + } +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR case CSSPropertyWebkitTapHighlightColor: { HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor); diff --git a/WebCore/platform/graphics/Color.h b/WebCore/platform/graphics/Color.h index 9335bc4..ae728c2 100644 --- a/WebCore/platform/graphics/Color.h +++ b/WebCore/platform/graphics/Color.h @@ -150,6 +150,13 @@ public: static const RGBA32 lightGray = 0xFFC0C0C0; static const RGBA32 transparent = 0x00000000; +#ifdef ANDROID_CSS_RING + static const RGBA32 ringFill = 0x80FFC64B; + static const RGBA32 ringPressedInner = 0xFFFEBD3A; + static const RGBA32 ringPressedOuter = 0xFFAD5C0A; + static const RGBA32 ringSelectedInner = 0xFFFE9230; + static const RGBA32 ringSelectedOuter = 0xFFB33F08; +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR static const RGBA32 tap = 0x4D1A1A1A; #endif diff --git a/WebCore/platform/graphics/android/android_graphics.cpp b/WebCore/platform/graphics/android/android_graphics.cpp index fafd3df..a780dc4 100644 --- a/WebCore/platform/graphics/android/android_graphics.cpp +++ b/WebCore/platform/graphics/android/android_graphics.cpp @@ -25,6 +25,7 @@ #include "CachedPrefix.h" #include "android_graphics.h" +#include "CachedColor.h" #include "CachedRoot.h" #include "IntRect.h" #include "LayerAndroid.h" @@ -36,30 +37,8 @@ namespace android { -/////////////////////////////////////////////////////////////////////////////// - -const static SkColor cursorOuterColors[] = { - SkColorSetARGB(0xff, 0xB3, 0x3F, 0x08), // normal ring select - SkColorSetARGB(0xff, 0x46, 0xb0, 0x00), // fake ring select, for phone, email, text - SkColorSetARGB(0xff, 0xAD, 0x5C, 0x0A), // normal ring pressed - SkColorSetARGB(0xff, 0x36, 0xc0, 0x00) // fake ring pressed -}; - -const static SkColor cursorInnerColors[] = { - SkColorSetARGB(0xff, 0xFE, 0x92, 0x30), // normal ring select - SkColorSetARGB(0xff, 0x8c, 0xd9, 0x00), // fake ring select, for phone, email, text - SkColorSetARGB(0xff, 0xFE, 0xBD, 0x3A), // normal ring pressed - SkColorSetARGB(0xff, 0x7c, 0xe9, 0x00) // fake ring pressed -}; - -const static SkColor cursorPressedColors[] = { - SkColorSetARGB(0x80, 0xFF, 0xC6, 0x4B), // normal ring pressed - SkColorSetARGB(0x80, 0x7c, 0xe9, 0x00) // fake ring pressed -}; - -#define CURSOR_RING_ROUNDEDNESS SkIntToScalar(5) // used to draw corners -#define CURSOR_RING_INNER_DIAMETER SkFixedToScalar(SkIntToFixed(3)>>1) // 3/2 == 1.5 -#define CURSOR_RING_OUTER_OUTSET 2 // used to inflate rects added to region +// The CSS values for the inner and outer widths may be specified as fractions +#define WIDTH_SCALE 0.0625f // 1/16, to offset the scale in CSSStyleSelector void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer) { @@ -75,6 +54,7 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer) m_followedLink = false; return; } + const CachedColor& colors = m_frame->color(m_node); unsigned rectCount = m_rings.size(); SkRegion rgn; SkPath path; @@ -84,24 +64,36 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer) SkIRect ir; r.round(&ir); - ir.inset(-CURSOR_RING_OUTER_OUTSET, -CURSOR_RING_OUTER_OUTSET); + ir.inset(-colors.outset(), -colors.outset()); rgn.op(ir, SkRegion::kUnion_Op); } rgn.getBoundaryPath(&path); SkPaint paint; paint.setAntiAlias(true); - paint.setPathEffect(new SkCornerPathEffect(CURSOR_RING_ROUNDEDNESS))->unref(); + paint.setPathEffect(new SkCornerPathEffect( + SkIntToScalar(colors.radius())))->unref(); + SkColor outer; + SkColor inner; if (m_flavor >= NORMAL_ANIMATING) { // pressed - paint.setColor(cursorPressedColors[m_flavor - NORMAL_ANIMATING]); + SkColor pressed; + pressed = colors.fillColor(); + paint.setColor(pressed); canvas->drawPath(path, paint); } + if (m_flavor >= NORMAL_ANIMATING) { + outer = colors.pressedOuterColor(); + inner = colors.pressedInnerColor(); + } else { + outer = colors.selectedOuterColor(); + inner = colors.selectedInnerColor(); + } paint.setStyle(SkPaint::kStroke_Style); - paint.setStrokeWidth(CURSOR_RING_OUTER_DIAMETER); - paint.setColor(cursorOuterColors[m_flavor]); + paint.setStrokeWidth(colors.outerWidth() * WIDTH_SCALE); + paint.setColor(outer); canvas->drawPath(path, paint); - paint.setStrokeWidth(CURSOR_RING_INNER_DIAMETER); - paint.setColor(cursorInnerColors[m_flavor]); + paint.setStrokeWidth(colors.innerWidth() * WIDTH_SCALE); + paint.setColor(inner); canvas->drawPath(path, paint); } @@ -140,7 +132,8 @@ bool CursorRing::setup() m_rings.clear(); m_rings.append(m_bounds); } - m_bounds.inflate(SkScalarCeil(CURSOR_RING_OUTER_DIAMETER)); + const CachedColor& colors = m_frame->color(m_node); + m_bounds.inflate(SkScalarCeil(colors.outerWidth())); if (!m_node->hasCursorRing() || (m_node->isPlugin() && m_node->isFocus())) return false; m_flavor = NORMAL_FLAVOR; @@ -159,6 +152,12 @@ bool CursorRing::setup() m_flavor == FAKE_ANIMATING ? "FAKE_ANIMATING" : "NORMAL_FLAVOR", m_rings.size(), ring.x(), ring.y(), ring.width(), ring.height(), m_node->isPlugin() ? "true" : "false"); + DBG_NAV_LOGD("[%d] inner=%d outer=%d outset=%d radius=%d" + " fill=0x%08x pin=0x%0x08x pout=0x%0x08x sin=0x%08x sout=0x%08x", + m_node->colorIndex(), colors.innerWidth(), colors.outerWidth(), + colors.outset(), colors.radius(), colors.fillColor(), + colors.pressedInnerColor(), colors.pressedOuterColor(), + colors.selectedInnerColor(), colors.selectedInnerColor()); #endif } return true; diff --git a/WebCore/platform/graphics/android/android_graphics.h b/WebCore/platform/graphics/android/android_graphics.h index dbf1978..b42231d 100644 --- a/WebCore/platform/graphics/android/android_graphics.h +++ b/WebCore/platform/graphics/android/android_graphics.h @@ -49,9 +49,6 @@ class WebViewCore; // used to inflate node cache entry #define CURSOR_RING_HIT_TEST_RADIUS 5 -// used to inval rectangle enclosing pressed state of ring -#define CURSOR_RING_OUTER_DIAMETER SkFixedToScalar(SkIntToFixed(13)>>2) // 13/4 == 3.25 - class CursorRing : public DrawExtra { public: enum Flavor { diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h index 58af7cf..8c8a8f9 100644 --- a/WebCore/rendering/style/RenderStyle.h +++ b/WebCore/rendering/style/RenderStyle.h @@ -715,6 +715,19 @@ public: bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; } ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); } +#ifdef ANDROID_CSS_RING + // called when building nav cache to determine if the ring data is unchanged + const void* ringData() const { return reinterpret_cast<const void*>(rareInheritedData.get()); } + Color ringFillColor() const { return rareInheritedData->ringFillColor; } + Length ringInnerWidth() const { return rareInheritedData->ringInnerWidth; } + Length ringOuterWidth() const { return rareInheritedData->ringOuterWidth; } + Length ringOutset() const { return rareInheritedData->ringOutset; } + Color ringPressedInnerColor() const { return rareInheritedData->ringPressedInnerColor; } + Color ringPressedOuterColor() const { return rareInheritedData->ringPressedOuterColor; } + Length ringRadius() const { return rareInheritedData->ringRadius; } + Color ringSelectedInnerColor() const { return rareInheritedData->ringSelectedInnerColor; } + Color ringSelectedOuterColor() const { return rareInheritedData->ringSelectedOuterColor; } +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; } #endif @@ -1051,6 +1064,21 @@ public: void setTextSizeAdjust(bool b) { SET_VAR(rareInheritedData, textSizeAdjust, b); } void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); } +#ifdef ANDROID_CSS_RING + void setRingFillColor(const Color& v) { SET_VAR(rareInheritedData, ringFillColor, v); } + void setRingInnerWidth(Length v) { SET_VAR(rareInheritedData, ringInnerWidth, v); } + void setRingOuterWidth(Length v) { SET_VAR(rareInheritedData, ringOuterWidth, v); } + void setRingOutset(Length v) { SET_VAR(rareInheritedData, ringOutset, v); } + void setRingPressedInnerColor(const Color& v) { + SET_VAR(rareInheritedData, ringPressedInnerColor, v); } + void setRingPressedOuterColor(const Color& v) { + SET_VAR(rareInheritedData, ringPressedOuterColor, v); } + void setRingRadius(Length v) { SET_VAR(rareInheritedData, ringRadius, v); } + void setRingSelectedInnerColor(const Color& v) { + SET_VAR(rareInheritedData, ringSelectedInnerColor, v); } + void setRingSelectedOuterColor(const Color& v) { + SET_VAR(rareInheritedData, ringSelectedOuterColor, v); } +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR void setTapHighlightColor(const Color& v) { SET_VAR(rareInheritedData, tapHighlightColor, v); } #endif @@ -1234,6 +1262,17 @@ public: static const Vector<StyleDashboardRegion>& noneDashboardRegions(); #endif +#ifdef ANDROID_CSS_RING + static Color initialRingFillColor() { return Color::ringFill; } + static Length initialRingInnerWidth() { return Length(24, Fixed); } // 1.5 + static Length initialRingOuterWidth() { return Length(52, Fixed); } // 3.25 + static Length initialRingOutset() { return Length(2, Fixed); } + static Color initialRingSelectedInnerColor() { return Color::ringSelectedInner; } + static Color initialRingSelectedOuterColor() { return Color::ringSelectedOuter; } + static Color initialRingPressedInnerColor() { return Color::ringPressedInner; } + static Color initialRingPressedOuterColor() { return Color::ringPressedOuter; } + static Length initialRingRadius() { return Length(5, Fixed); } +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR static Color initialTapHighlightColor() { return Color::tap; } #endif diff --git a/WebCore/rendering/style/StyleRareInheritedData.cpp b/WebCore/rendering/style/StyleRareInheritedData.cpp index cb6edf3..31012a6 100644 --- a/WebCore/rendering/style/StyleRareInheritedData.cpp +++ b/WebCore/rendering/style/StyleRareInheritedData.cpp @@ -29,6 +29,17 @@ namespace WebCore { StyleRareInheritedData::StyleRareInheritedData() : textStrokeWidth(RenderStyle::initialTextStrokeWidth()) +#ifdef ANDROID_CSS_RING + , ringFillColor(RenderStyle::initialRingFillColor()) + , ringInnerWidth(RenderStyle::initialRingInnerWidth()) + , ringOuterWidth(RenderStyle::initialRingOuterWidth()) + , ringOutset(RenderStyle::initialRingOutset()) + , ringPressedInnerColor(RenderStyle::initialRingPressedInnerColor()) + , ringPressedOuterColor(RenderStyle::initialRingPressedOuterColor()) + , ringRadius(RenderStyle::initialRingRadius()) + , ringSelectedInnerColor(RenderStyle::initialRingSelectedInnerColor()) + , ringSelectedOuterColor(RenderStyle::initialRingSelectedOuterColor()) +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR , tapHighlightColor(RenderStyle::initialTapHighlightColor()) #endif @@ -56,6 +67,17 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o) , textStrokeColor(o.textStrokeColor) , textStrokeWidth(o.textStrokeWidth) , textFillColor(o.textFillColor) +#ifdef ANDROID_CSS_RING + , ringFillColor(o.ringFillColor) + , ringInnerWidth(o.ringInnerWidth) + , ringOuterWidth(o.ringOuterWidth) + , ringOutset(o.ringOutset) + , ringPressedInnerColor(o.ringPressedInnerColor) + , ringPressedOuterColor(o.ringPressedOuterColor) + , ringRadius(o.ringRadius) + , ringSelectedInnerColor(o.ringSelectedInnerColor) + , ringSelectedOuterColor(o.ringSelectedOuterColor) +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR , tapHighlightColor(o.tapHighlightColor) #endif @@ -114,6 +136,17 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const && nbspMode == o.nbspMode && khtmlLineBreak == o.khtmlLineBreak && textSizeAdjust == o.textSizeAdjust +#ifdef ANDROID_CSS_RING + && ringFillColor == o.ringFillColor + && ringInnerWidth == o.ringInnerWidth + && ringOuterWidth == o.ringOuterWidth + && ringOutset == o.ringOutset + && ringPressedInnerColor == o.ringPressedInnerColor + && ringPressedOuterColor == o.ringPressedOuterColor + && ringRadius == o.ringRadius + && ringSelectedInnerColor == o.ringSelectedInnerColor + && ringSelectedOuterColor == o.ringSelectedOuterColor +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR && tapHighlightColor == o.tapHighlightColor #endif diff --git a/WebCore/rendering/style/StyleRareInheritedData.h b/WebCore/rendering/style/StyleRareInheritedData.h index f6e3bf4..b32392d 100644 --- a/WebCore/rendering/style/StyleRareInheritedData.h +++ b/WebCore/rendering/style/StyleRareInheritedData.h @@ -55,6 +55,17 @@ public: Color textStrokeColor; float textStrokeWidth; Color textFillColor; +#ifdef ANDROID_CSS_RING + Color ringFillColor; + Length ringInnerWidth; + Length ringOuterWidth; + Length ringOutset; + Color ringPressedInnerColor; + Color ringPressedOuterColor; + Length ringRadius; + Color ringSelectedInnerColor; + Color ringSelectedOuterColor; +#endif #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR Color tapHighlightColor; #endif diff --git a/WebKit/Android.mk b/WebKit/Android.mk index ce72d65..9cff88b 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -68,6 +68,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ android/jni/WebViewCore.cpp \ \ android/nav/CacheBuilder.cpp \ + android/nav/CachedColor.cpp \ android/nav/CachedFrame.cpp \ android/nav/CachedHistory.cpp \ android/nav/CachedInput.cpp \ diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 5fddc48..44397bf 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -928,6 +928,35 @@ static void AddLayer(CachedFrame* frame, size_t index, const IntPoint& location, } #endif +static int FindColorIndex(WTF::Vector<CachedColor>& colorTracker, + const CachedColor& cachedColor) +{ + CachedColor* work = colorTracker.begin() - 1; + CachedColor* end = colorTracker.end(); + while (++work < end) { + if (*work == cachedColor) + return work - colorTracker.begin(); + } + int result = colorTracker.size(); + colorTracker.grow(result + 1); + CachedColor& newColor = colorTracker.last(); + newColor = cachedColor; + return result; +} + +static void InitColor(CachedColor* color) +{ + color->setFillColor(RenderStyle::initialRingFillColor()); + color->setInnerWidth(RenderStyle::initialRingInnerWidth()); + color->setOuterWidth(RenderStyle::initialRingOuterWidth()); + color->setOutset(RenderStyle::initialRingOutset()); + color->setPressedInnerColor(RenderStyle::initialRingPressedInnerColor()); + color->setPressedOuterColor(RenderStyle::initialRingPressedOuterColor()); + color->setRadius(RenderStyle::initialRingRadius()); + color->setSelectedInnerColor(RenderStyle::initialRingSelectedInnerColor()); + color->setSelectedOuterColor(RenderStyle::initialRingSelectedOuterColor()); +} + // when new focus is found, push it's parent on a stack // as long as more focii are found with the same (grand) parent, note it // (which only requires retrieving the last parent on the stack) @@ -955,6 +984,8 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, bzero(clipTracker.data(), sizeof(ClipColumnTracker)); WTF::Vector<TabIndexTracker> tabIndexTracker(1); // sentinel bzero(tabIndexTracker.data(), sizeof(TabIndexTracker)); + WTF::Vector<CachedColor> colorTracker(1); + InitColor(colorTracker.data()); #if DUMP_NAV_CACHE char* frameNamePtr = cachedFrame->mDebug.mFrameName; Builder(frame)->mDebug.frameName(frameNamePtr, frameNamePtr + @@ -970,9 +1001,12 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, #if DUMP_NAV_CACHE cachedParentNode.mDebug.mNodeIndex = nodeIndex; #endif + cachedFrame->add(colorTracker[0]); cachedFrame->add(cachedParentNode); Node* node = parent; int cacheIndex = 1; + int colorIndex = 0; // assume no special css ring colors + const void* lastStyleDataPtr = 0; int textInputIndex = 0; Node* focused = doc->focusedNode(); if (focused) @@ -1104,6 +1138,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, TextDirection direction = LTR; String exported; CachedNodeType type = NORMAL_CACHEDNODETYPE; + CachedColor cachedColor; CachedInput cachedInput; IntRect bounds; IntRect absBounds; @@ -1294,6 +1329,25 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, globalOffsetX, globalOffsetY, &cachedNode.mCursorRing) == false) continue; keepTextNode: + RenderStyle* style = nodeRenderer->style(); + const void* styleDataPtr = style->ringData(); + // to save time, see if we're pointing to the same style data as before + if (lastStyleDataPtr != styleDataPtr) { + lastStyleDataPtr = styleDataPtr; + cachedColor.setFillColor(style->ringFillColor()); + cachedColor.setInnerWidth(style->ringInnerWidth()); + cachedColor.setOuterWidth(style->ringOuterWidth()); + cachedColor.setOutset(style->ringOutset()); + cachedColor.setPressedInnerColor(style->ringPressedInnerColor()); + cachedColor.setPressedOuterColor(style->ringPressedOuterColor()); + cachedColor.setRadius(style->ringRadius()); + cachedColor.setSelectedInnerColor(style->ringSelectedInnerColor()); + cachedColor.setSelectedOuterColor(style->ringSelectedOuterColor()); + int oldSize = colorTracker.size(); + colorIndex = FindColorIndex(colorTracker, cachedColor); + if (colorIndex == oldSize) + cachedFrame->add(cachedColor); + } IntRect clip = hasClip ? bounds : absBounds; size_t clipIndex = clipTracker.size(); if (clipTracker.last().mNode == node) @@ -1334,6 +1388,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, } #endif cachedNode.setNavableRects(); + cachedNode.setColorIndex(colorIndex); cachedNode.setExport(exported); cachedNode.setHasCursorRing(hasCursorRing); cachedNode.setHasMouseOver(hasMouseOver); diff --git a/WebKit/android/nav/CachedColor.cpp b/WebKit/android/nav/CachedColor.cpp new file mode 100644 index 0000000..c610022 --- /dev/null +++ b/WebKit/android/nav/CachedColor.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "CachedPrefix.h" +#include "CachedColor.h" + +namespace android { + +#if DUMP_NAV_CACHE + +#define DEBUG_PRINT_COLOR(field) \ + DUMP_NAV_LOGD("// SkColor " #field "=0x%08x;\n", b->field) + +CachedColor* CachedColor::Debug::base() const { + CachedColor* nav = (CachedColor*) ((char*) this - OFFSETOF(CachedColor, mDebug)); + return nav; +} + +void CachedColor::Debug::print() const +{ + CachedColor* b = base(); + DEBUG_PRINT_COLOR(mFillColor); + DUMP_NAV_LOGD("// int mInnerWidth=%d;\n", b->mInnerWidth); + DUMP_NAV_LOGD("// int mOuterWidth=%d;\n", b->mOuterWidth); + DUMP_NAV_LOGD("// int mOutset=%d;\n", b->mOutset); + DEBUG_PRINT_COLOR(mPressedInnerColor); + DEBUG_PRINT_COLOR(mPressedOuterColor); + DUMP_NAV_LOGD("// int mRadius=%d;\n", b->mRadius); + DEBUG_PRINT_COLOR(mSelectedInnerColor); + DEBUG_PRINT_COLOR(mSelectedOuterColor); +} + +#endif + +} + diff --git a/WebKit/android/nav/CachedColor.h b/WebKit/android/nav/CachedColor.h new file mode 100644 index 0000000..4b39810 --- /dev/null +++ b/WebKit/android/nav/CachedColor.h @@ -0,0 +1,87 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CachedColor_H +#define CachedColor_H + +#include "CachedDebug.h" +#include "Color.h" +#include "Length.h" +#include "SkColor.h" + +using namespace WebCore; + +namespace android { + +class CachedColor { +public: + CachedColor() { + // Initiaized to 0 in its array, so nothing to do in the + // constructor + } + bool operator==(const CachedColor& o) const { + return memcmp(&o, this, sizeof(this)) == 0; } + SkColor fillColor() const { return mFillColor; } + void init(); + int innerWidth() const { return mInnerWidth; } + int outerWidth() const { return mOuterWidth; } + int outset() const { return mOutset; } + SkColor pressedInnerColor() const { return mPressedInnerColor; } + SkColor pressedOuterColor() const { return mPressedOuterColor; } + int radius() const { return mRadius; } + SkColor selectedInnerColor() const { return mSelectedInnerColor; } + SkColor selectedOuterColor() const { return mSelectedOuterColor; } + void setFillColor(const Color& c) { mFillColor = c.rgb(); } + void setInnerWidth(Length l) { mInnerWidth = l.value(); } + void setOuterWidth(Length l) { mOuterWidth = l.value(); } + void setOutset(Length l) { mOutset = l.value(); } + void setPressedInnerColor(const Color& c) { mPressedInnerColor = c.rgb(); } + void setPressedOuterColor(const Color& c) { mPressedOuterColor = c.rgb(); } + void setRadius(Length l) { mRadius = l.value(); } + void setSelectedInnerColor(const Color& c) { mSelectedInnerColor = c.rgb(); } + void setSelectedOuterColor(const Color& c) { mSelectedOuterColor = c.rgb(); } +private: + SkColor mFillColor; + int mInnerWidth; + int mOuterWidth; + int mOutset; + SkColor mPressedInnerColor; + SkColor mPressedOuterColor; + int mRadius; + SkColor mSelectedInnerColor; + SkColor mSelectedOuterColor; +#if DUMP_NAV_CACHE +public: + class Debug { +public: + CachedColor* base() const; + void print() const; + } mDebug; +#endif +}; + +} + +#endif diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp index ff13508..1187ed7 100644 --- a/WebKit/android/nav/CachedFrame.cpp +++ b/WebKit/android/nav/CachedFrame.cpp @@ -1401,6 +1401,12 @@ void CachedFrame::Debug::print() const } DUMP_NAV_LOGD("// }; // end of layers\n"); #endif // USE(ACCELERATED_COMPOSITING) + DUMP_NAV_LOGD("// CachedColor mCachedColors={ // count=%d\n", b->mCachedColors.size()); + for (CachedColor* color = b->mCachedColors.begin(); + color != b->mCachedColors.end(); color++) { + color->mDebug.print(); + } + DUMP_NAV_LOGD("// }; // end of colors\n"); DUMP_NAV_LOGD("// CachedFrame mCachedFrames={ // count=%d\n", b->mCachedFrames.size()); for (CachedFrame* child = b->mCachedFrames.begin(); child != b->mCachedFrames.end(); child++) diff --git a/WebKit/android/nav/CachedFrame.h b/WebKit/android/nav/CachedFrame.h index 9334707..257ced8 100644 --- a/WebKit/android/nav/CachedFrame.h +++ b/WebKit/android/nav/CachedFrame.h @@ -26,6 +26,7 @@ #ifndef CachedFrame_H #define CachedFrame_H +#include "CachedColor.h" #include "CachedInput.h" #include "CachedLayer.h" #include "CachedNode.h" @@ -70,6 +71,7 @@ public: CURSOR_SET = 0 }; CachedFrame() {} + void add(CachedColor& color) { mCachedColors.append(color); } void add(CachedInput& input) { mCachedTextInputs.append(input); } #if USE(ACCELERATED_COMPOSITING) void add(CachedLayer& layer) { mCachedLayers.append(layer); } @@ -84,6 +86,9 @@ public: bool checkVisited(const CachedNode* , CachedFrame::Direction ) const; size_t childCount() { return mCachedFrames.size(); } void clearCursor(); + const CachedColor& color(const CachedNode* node) const { + return mCachedColors[node->colorIndex()]; + } const CachedNode* currentCursor() const { return currentCursor(NULL); } const CachedNode* currentCursor(const CachedFrame** ) const; const CachedNode* currentFocus() const { return currentFocus(NULL); } @@ -224,6 +229,7 @@ private: // since computing these is complicated, protect them so that the WebCore::IntRect mContents; WebCore::IntRect mLocalViewBounds; WebCore::IntRect mViewBounds; + WTF::Vector<CachedColor> mCachedColors; WTF::Vector<CachedNode> mCachedNodes; WTF::Vector<CachedFrame> mCachedFrames; WTF::Vector<CachedInput> mCachedTextInputs; diff --git a/WebKit/android/nav/CachedNode.cpp b/WebKit/android/nav/CachedNode.cpp index 8fc5f5b..d6f8891 100644 --- a/WebKit/android/nav/CachedNode.cpp +++ b/WebKit/android/nav/CachedNode.cpp @@ -404,6 +404,7 @@ void CachedNode::Debug::print() const DUMP_NAV_LOGD("// int mNavableRects=%d;\n", b->mNavableRects); DUMP_NAV_LOGD("// int mParentIndex=%d;\n", b->mParentIndex); DUMP_NAV_LOGD("// int mTabIndex=%d;\n", b->mTabIndex); + DUMP_NAV_LOGD("// int mColorIndex=%d;\n", b->mColorIndex); DUMP_NAV_LOGD("// Condition mCondition=%s;\n", condition(b->mCondition)); DUMP_NAV_LOGD("// Type mType=%s;\n", type(b->mType)); DEBUG_PRINT_BOOL(mClippedOut); diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h index 09f53c3..4539eab 100644 --- a/WebKit/android/nav/CachedNode.h +++ b/WebKit/android/nav/CachedNode.h @@ -95,6 +95,7 @@ public: WTF::Vector<WebCore::IntRect>* rings); bool clip(const WebCore::IntRect& ); bool clippedOut() { return mClippedOut; } + int colorIndex() const { return mColorIndex; } WebCore::IntRect cursorRingBounds(const CachedFrame* ) const; void cursorRings(const CachedFrame* , WTF::Vector<WebCore::IntRect>* ) const; bool disabled() const { return mDisabled; } @@ -147,6 +148,7 @@ public: WebCore::IntRect ring(const CachedFrame* , size_t part) const; void setBounds(const WebCore::IntRect& bounds) { mBounds = bounds; } void setClippedOut(bool clipped) { mClippedOut = clipped; } + void setColorIndex(int index) { mColorIndex = index; } void setCondition(Condition condition) const { mCondition = condition; } void setDataIndex(int index) { mDataIndex = index; } void setDisabled(bool disabled) { mDisabled = disabled; } @@ -190,6 +192,7 @@ private: int mNavableRects; // FIXME: could be bitfield once I limit max number of rects int mParentIndex; int mTabIndex; + int mColorIndex; // index to ring color and other stylable properties mutable Condition mCondition : 5; // why the node was not chosen on the first pass CachedNodeType mType : 4; bool mClippedOut : 1; |