diff options
40 files changed, 959 insertions, 100 deletions
@@ -56,7 +56,7 @@ JAVASCRIPT_ENGINE = $(JS_ENGINE) # We default to the V8 JS engine on everything except the simulator where # we stick with JSC. -ifeq ($(TARGET_SIMULATOR),false) +ifneq ($(TARGET_SIMULATOR),true) DEFAULT_ENGINE = v8 ALT_ENGINE = jsc else @@ -76,9 +76,9 @@ ifneq ($(JAVASCRIPT_ENGINE),jsc) endif # Read the HTTP_STACK environment variable, default is android -ifeq ($(TARGET_SIMULATOR),false) +ifneq ($(TARGET_SIMULATOR),true) HTTP_STACK = $(HTTP) -ifneq ($(HTTP_STACK),android) +ifeq ($(HTTP_STACK),chrome) # Chrome net stack has dependencies on V8. ifeq ($(JAVASCRIPT_ENGINE), v8) HTTP_STACK = chrome diff --git a/CleanSpec.mk b/CleanSpec.mk index 586a7ae..ce051f9 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -60,6 +60,8 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_int $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libwebcore_intermediates) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libwebcore_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libwebcore_intermediates) # ************************************************ diff --git a/LayoutTests/platform/android/test_expectations.txt b/LayoutTests/platform/android/test_expectations.txt index f2979da..b3757f5 100644 --- a/LayoutTests/platform/android/test_expectations.txt +++ b/LayoutTests/platform/android/test_expectations.txt @@ -43,8 +43,6 @@ ietestcenter/Javascript/15.4.4.15-3-8.html SKIP // hangs the layout tests http:/ // This first block of tests are for features for which Android // should pass all tests. They are skipped only temporarily. // TODO: Fix these failing tests and remove them from this list. -fast/dom/Geolocation/delayed-permission-allowed.html IGNORE_RESULT // Requires layoutTestController.permissionSet b/2914450 -fast/dom/Geolocation/delayed-permission-denied.html IGNORE_RESULT // Requires layoutTestController.permissionSet b/2914450 fast/events/touch/basic-multi-touch-events.html IGNORE_RESULT // Requires multi-touch fast/events/touch/touch-target.html IGNORE_RESULT // Requires multi-touch http/tests/appcache/empty-manifest.html IGNORE_RESULT // flaky diff --git a/WebCore/Android.derived.mk b/WebCore/Android.derived.mk index 7a9611b..2111e6e 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 fc81dff..0575422 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 6bb025d..418251f 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 @@ -1540,6 +1552,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 a084474..cdd6294 100644 --- a/WebCore/css/CSSParser.cpp +++ b/WebCore/css/CSSParser.cpp @@ -1816,6 +1816,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 1a79602..d236b45 100644 --- a/WebCore/css/CSSPropertyNames.in +++ b/WebCore/css/CSSPropertyNames.in @@ -255,9 +255,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 40b11d9..bd94b68 100644 --- a/WebCore/css/CSSStyleSelector.cpp +++ b/WebCore/css/CSSStyleSelector.cpp @@ -5556,6 +5556,138 @@ 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) + if (!primitiveValue) + break; + 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 + RefPtr<CSSPrimitiveValue> scaledValue = CSSPrimitiveValue::create( + primitiveValue->getFloatValue() * 16, + (CSSPrimitiveValue::UnitTypes) type); + l = Length(scaledValue->computeLengthIntForLength(style(), + m_rootElementStyle, zoomFactor), Fixed); + scaledValue.release(); + } 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) + if (!primitiveValue) + break; + 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 + RefPtr<CSSPrimitiveValue> scaledValue = CSSPrimitiveValue::create( + primitiveValue->getFloatValue() * 16, + (CSSPrimitiveValue::UnitTypes) type); + l = Length(scaledValue->computeLengthIntForLength(style(), + m_rootElementStyle, zoomFactor), Fixed); + scaledValue.release(); + } 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) + if (!primitiveValue) + break; + 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) + if (!primitiveValue) + break; + 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/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index e8722e2..4eeaa6c 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -81,6 +81,7 @@ class NPObject; namespace WebCore { +class Document; class FrameView; class Widget; @@ -100,9 +101,9 @@ public: static WTF::Vector<String> getSupportedKeyStrengthList(); static String getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL&); // Cookies - static void setCookies(const KURL&, const String& value); - static String cookies(const KURL&); - static bool cookiesEnabled(); + static void setCookies(const Document*, const KURL&, const String& value); + static String cookies(const Document*, const KURL&); + static bool cookiesEnabled(const Document*); // Plugin static NPObject* pluginScriptableObject(Widget*); // Popups diff --git a/WebCore/platform/graphics/Color.h b/WebCore/platform/graphics/Color.h index 81480b6..22a8a8f 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 a5dafda..f8032c4 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); } @@ -141,8 +133,9 @@ bool CursorRing::setup() m_rings.append(m_bounds); } m_absBounds = m_node->bounds(m_frame); - m_bounds.inflate(SkScalarCeil(CURSOR_RING_OUTER_DIAMETER)); - m_absBounds.inflate(SkScalarCeil(CURSOR_RING_OUTER_DIAMETER)); + const CachedColor& colors = m_frame->color(m_node); + m_bounds.inflate(SkScalarCeil(colors.outerWidth())); + m_absBounds.inflate(SkScalarCeil(colors.outerWidth())); if (!m_node->hasCursorRing() || (m_node->isPlugin() && m_node->isFocus())) return false; m_flavor = NORMAL_FLAVOR; @@ -161,6 +154,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 46c60e8..09482bd 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/platform/network/android/CookieJarAndroid.cpp b/WebCore/platform/network/android/CookieJarAndroid.cpp index dd324c5..f3b343e 100644 --- a/WebCore/platform/network/android/CookieJarAndroid.cpp +++ b/WebCore/platform/network/android/CookieJarAndroid.cpp @@ -31,25 +31,25 @@ namespace WebCore { -void setCookies(Document*, const KURL& url, const String& value) +void setCookies(Document* document, const KURL& url, const String& value) { - PlatformBridge::setCookies(url, value); + PlatformBridge::setCookies(document, url, value); } -String cookies(const Document*, const KURL& url) +String cookies(const Document* document, const KURL& url) { - return PlatformBridge::cookies(url); + return PlatformBridge::cookies(document, url); } -String cookieRequestHeaderFieldValue(const Document*, const KURL& url) +String cookieRequestHeaderFieldValue(const Document* document, const KURL& url) { // FIXME: include HttpOnly cookie. - return PlatformBridge::cookies(url); + return PlatformBridge::cookies(document, url); } -bool cookiesEnabled(const Document*) +bool cookiesEnabled(const Document* document) { - return PlatformBridge::cookiesEnabled(); + return PlatformBridge::cookiesEnabled(document); } } diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h index 234122e..df32d6b 100644 --- a/WebCore/rendering/style/RenderStyle.h +++ b/WebCore/rendering/style/RenderStyle.h @@ -716,6 +716,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 @@ -1053,6 +1066,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 @@ -1237,6 +1265,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 6942809..42f2030 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 @@ -115,6 +137,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 74d5fc9..07541d3 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 4f16f4c..01ede0f 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -55,6 +55,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ \ android/icu/unicode/ucnv.cpp \ \ + android/jni/DeviceOrientationClientImpl.cpp \ android/jni/DeviceOrientationManager.cpp \ android/jni/GeolocationPermissionsBridge.cpp \ android/jni/JavaBridge.cpp \ @@ -73,6 +74,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/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 31e3101..754e4d9 100644 --- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -27,11 +27,13 @@ #include <PlatformBridge.h> #include "CookieClient.h" +#include "Document.h" #include "FileSystemClient.h" #include "FrameView.h" #include "JavaSharedClient.h" #include "KeyGeneratorClient.h" #include "PluginView.h" +#include "Settings.h" #include "WebCoreFrameBridge.h" #include "WebRequestContext.h" #include "WebViewCore.h" @@ -61,12 +63,17 @@ String PlatformBridge::getSignedPublicKeyAndChallengeString(unsigned index, cons return client->getSignedPublicKeyAndChallengeString(index, challenge, url); } -void PlatformBridge::setCookies(const KURL& url, const String& value) +void PlatformBridge::setCookies(const Document* document, const KURL& url, const String& value) { #if USE(CHROME_NETWORK_STACK) std::string cookieValue(value.utf8().data()); GURL cookieGurl(url.string().utf8().data()); - WebRequestContext::GetAndroidContext()->cookie_store()->SetCookie(cookieGurl ,cookieValue); + WebRequestContext* androidContext; + if (document->settings() && document->settings()->privateBrowsingEnabled()) + androidContext = WebRequestContext::GetAndroidPrivateBrowsingContext(); + else + androidContext = WebRequestContext::GetAndroidContext(); + androidContext->cookie_store()->SetCookie(cookieGurl, cookieValue); #else CookieClient* client = JavaSharedClient::GetCookieClient(); if (!client) @@ -76,11 +83,16 @@ void PlatformBridge::setCookies(const KURL& url, const String& value) #endif } -String PlatformBridge::cookies(const KURL& url) +String PlatformBridge::cookies(const Document* document, const KURL& url) { #if USE(CHROME_NETWORK_STACK) GURL cookieGurl(url.string().utf8().data()); - std::string cookies = WebRequestContext::GetAndroidContext()->cookie_store()->GetCookies(cookieGurl); + WebRequestContext* androidContext; + if (document->settings() && document->settings()->privateBrowsingEnabled()) + androidContext = WebRequestContext::GetAndroidPrivateBrowsingContext(); + else + androidContext = WebRequestContext::GetAndroidContext(); + std::string cookies = androidContext->cookie_store()->GetCookies(cookieGurl); String cookieString(cookies.c_str()); return cookieString; #else @@ -92,7 +104,7 @@ String PlatformBridge::cookies(const KURL& url) #endif } -bool PlatformBridge::cookiesEnabled() +bool PlatformBridge::cookiesEnabled(const Document* document) { CookieClient* client = JavaSharedClient::GetCookieClient(); if (!client) diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp index 9118baf..79e780e 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.cpp +++ b/WebKit/android/WebCoreSupport/WebRequest.cpp @@ -51,7 +51,6 @@ namespace { WebRequest::WebRequest(WebUrlLoaderClient* loader, WebResourceRequest webResourceRequest) : m_urlLoader(loader) - , m_request(0) { GURL gurl(webResourceRequest.url()); m_request = new URLRequest(gurl, this); @@ -81,6 +80,7 @@ void WebRequest::finish(bool success) void WebRequest::AppendBytesToUpload(const char* bytes, int bytesLen) { + // This should always be called after start and before finish. m_request->AppendBytesToUpload(bytes, bytesLen); } @@ -100,8 +100,13 @@ void WebRequest::start(bool isPrivateBrowsing) void WebRequest::cancel() { - if (m_request) - m_request->Cancel(); + // There is a possible race condition between the IO thread finishing the request and + // the WebCore thread cancelling it. If the request has already finished, do + // nothing to avoid sending duplicate finish messages to WebCore. + if (!m_request) + return; + + m_request->Cancel(); finish(true); } diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp index 1de066e..6b2fe1b 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp +++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp @@ -36,10 +36,14 @@ #include <net/http/http_cache.h> #include <net/http/http_network_layer.h> #include <net/proxy/proxy_service.h> +#include <wtf/text/CString.h> namespace { - // TODO: Get uastring from webcore - std::string userAgent("Mozilla/5.0 (Linux; U; Android 2.1; en-gb; Nexus One Build/ERE21) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"); +std::string userAgent("Mozilla/5.0 (Linux; U; Android 2.1; en-gb; Nexus One Build/ERE21) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"); +std::string acceptLanguage(""); + +Lock userAgentLock; +Lock acceptLanguageLock; } namespace android { @@ -48,17 +52,39 @@ std::string* WebRequestContext::s_dataDirectory(0); WebRequestContext::WebRequestContext() { + // Also hardcoded in FrameLoader.java + accept_charset_ = "utf-8, iso-8859-1, utf-16, *;q=0.7"; } WebRequestContext::~WebRequestContext() { } +void WebRequestContext::SetUserAgent(WTF::String string) +{ + AutoLock aLock(userAgentLock); + userAgent = string.utf8().data(); + userAgent.append(" alternate http"); +} + const std::string& WebRequestContext::GetUserAgent(const GURL& url) const { + AutoLock aLock(userAgentLock); return userAgent; } +void WebRequestContext::SetAcceptLanguage(WTF::String string) +{ + AutoLock aLock(acceptLanguageLock); + acceptLanguage = string.utf8().data(); +} + +const std::string& WebRequestContext::GetAcceptLanguage() const +{ + AutoLock aLock(acceptLanguageLock); + return acceptLanguage; +} + const std::string* WebRequestContext::GetDataDirectory() { if (!s_dataDirectory) { diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.h b/WebKit/android/WebCoreSupport/WebRequestContext.h index c321528..a1f7973 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.h +++ b/WebKit/android/WebCoreSupport/WebRequestContext.h @@ -31,16 +31,23 @@ // a subclass of a chrome class. #if USE(CHROME_NETWORK_STACK) -#include "net/http/http_cache.h" -#include "net/url_request/url_request_context.h" +#include "PlatformString.h" + +#include <net/http/http_cache.h> +#include <net/url_request/url_request_context.h> namespace android { class WebRequestContext : public URLRequestContext { public: virtual const std::string& GetUserAgent(const GURL& url) const; + virtual const std::string& GetAcceptLanguage() const; static WebRequestContext* GetAndroidContext(); static WebRequestContext* GetAndroidPrivateBrowsingContext(); + + static void SetUserAgent(WTF::String); + static void SetAcceptLanguage(WTF::String); + private: static const std::string* GetDataDirectory(); static WebRequestContext* GetAndroidContextForPath(const char* cookiePath, const char* cachePath); @@ -49,6 +56,7 @@ private: // Caching this query from java static std::string* s_dataDirectory; + static std::string* s_userAgent; }; } // namespace android diff --git a/WebKit/android/jni/DeviceOrientationClientImpl.cpp b/WebKit/android/jni/DeviceOrientationClientImpl.cpp new file mode 100644 index 0000000..a295bf3 --- /dev/null +++ b/WebKit/android/jni/DeviceOrientationClientImpl.cpp @@ -0,0 +1,129 @@ +/* + * 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 "config.h" +#include "DeviceOrientationClientImpl.h" + +#include "WebViewCore.h" +#include <DeviceOrientationController.h> +#include <Frame.h> +#include <JNIHelp.h> + +namespace android { + +using JSC::Bindings::getJNIEnv; + +enum javaDeviceOrientationServiceClassMethods { + DeviceOrientationServiceMethodStart = 0, + DeviceOrientationServiceMethodStop, + DeviceOrientationServiceMethodSuspend, + DeviceOrientationServiceMethodResume, + DeviceOrientationServiceMethodCount +}; +static jmethodID javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodCount]; + +DeviceOrientationClientImpl::DeviceOrientationClientImpl(WebViewCore* webViewCore) + : m_webViewCore(webViewCore) + , m_javaDeviceOrientationServiceObject(0) +{ + ASSERT(m_webViewCore); +} + +DeviceOrientationClientImpl::~DeviceOrientationClientImpl() +{ + releaseJavaInstance(); +} + +jobject DeviceOrientationClientImpl::getJavaInstance() +{ + // Lazily get the Java object. We can't do this until the WebViewCore is all + // set up. + if (m_javaDeviceOrientationServiceObject) + return m_javaDeviceOrientationServiceObject; + + JNIEnv* env = getJNIEnv(); + + ASSERT(m_webViewCore); + jobject object = m_webViewCore->getDeviceOrientationService(); + + // Get the Java DeviceOrientationService class. + jclass javaDeviceOrientationServiceClass = env->GetObjectClass(object); + ASSERT(javaDeviceOrientationServiceClass); + + // Set up the methods we wish to call on the Java DeviceOrientationService + // class. + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodStart] = + env->GetMethodID(javaDeviceOrientationServiceClass, "start", "()V"); + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodStop] = + env->GetMethodID(javaDeviceOrientationServiceClass, "stop", "()V"); + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodSuspend] = + env->GetMethodID(javaDeviceOrientationServiceClass, "suspend", "()V"); + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodResume] = + env->GetMethodID(javaDeviceOrientationServiceClass, "resume", "()V"); + + m_javaDeviceOrientationServiceObject = getJNIEnv()->NewGlobalRef(object); + getJNIEnv()->DeleteLocalRef(object); + + ASSERT(m_javaDeviceOrientationServiceObject); + return m_javaDeviceOrientationServiceObject; +} + +void DeviceOrientationClientImpl::releaseJavaInstance() +{ + ASSERT(m_javaDeviceOrientationServiceObject); + getJNIEnv()->DeleteGlobalRef(m_javaDeviceOrientationServiceObject); +} + +void DeviceOrientationClientImpl::startUpdating() +{ + getJNIEnv()->CallVoidMethod(getJavaInstance(), + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodStart]); +} + +void DeviceOrientationClientImpl::stopUpdating() +{ + getJNIEnv()->CallVoidMethod(getJavaInstance(), + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodStop]); +} + +void DeviceOrientationClientImpl::onOrientationChange(PassRefPtr<DeviceOrientation> orientation) +{ + m_lastOrientation = orientation; + m_controller->didChangeDeviceOrientation(m_lastOrientation.get()); +} + +void DeviceOrientationClientImpl::suspend() +{ + getJNIEnv()->CallVoidMethod(getJavaInstance(), + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodSuspend]); +} + +void DeviceOrientationClientImpl::resume() +{ + getJNIEnv()->CallVoidMethod(getJavaInstance(), + javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodResume]); +} + +} // namespace android diff --git a/WebKit/android/jni/DeviceOrientationClientImpl.h b/WebKit/android/jni/DeviceOrientationClientImpl.h new file mode 100644 index 0000000..8514a6b --- /dev/null +++ b/WebKit/android/jni/DeviceOrientationClientImpl.h @@ -0,0 +1,70 @@ +/* + * 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 DeviceOrientationClientImpl_h +#define DeviceOrientationClientImpl_h + +#include <DeviceOrientation.h> +#include <DeviceOrientationClient.h> +#include <JNIUtility.h> +#include <PassRefPtr.h> +#include <RefPtr.h> + +using namespace WebCore; + +namespace android { + +class DeviceOrientationManager; +class WebViewCore; + +class DeviceOrientationClientImpl : public DeviceOrientationClient { +public: + DeviceOrientationClientImpl(WebViewCore*); + + void onOrientationChange(PassRefPtr<DeviceOrientation>); + void suspend(); + void resume(); + + // DeviceOrientationClient methods + virtual void startUpdating(); + virtual void stopUpdating(); + virtual DeviceOrientation* lastOrientation() const { return m_lastOrientation.get(); } + virtual void setController(DeviceOrientationController* controller) { m_controller = controller; } + +protected: + virtual ~DeviceOrientationClientImpl(); + + jobject getJavaInstance(); + void releaseJavaInstance(); + + WebViewCore* m_webViewCore; + jobject m_javaDeviceOrientationServiceObject; + DeviceOrientationController* m_controller; + RefPtr<DeviceOrientation> m_lastOrientation; +}; + +} // namespace android + +#endif // DeviceOrientationClientImpl_h diff --git a/WebKit/android/jni/DeviceOrientationManager.cpp b/WebKit/android/jni/DeviceOrientationManager.cpp index 8a48ce8..621e646 100644 --- a/WebKit/android/jni/DeviceOrientationManager.cpp +++ b/WebKit/android/jni/DeviceOrientationManager.cpp @@ -26,7 +26,12 @@ #include "config.h" #include "DeviceOrientationManager.h" +#include "DeviceOrientationClientImpl.h" +#include "DeviceOrientationController.h" #include "WebViewCore.h" +#include "Frame.h" +#include "Page.h" + #include <DeviceOrientationClientMock.h> #include <JNIHelp.h> @@ -34,8 +39,9 @@ using namespace WebCore; namespace android { -DeviceOrientationManager::DeviceOrientationManager() +DeviceOrientationManager::DeviceOrientationManager(WebViewCore* webViewCore) : m_useMock(false) + , m_webViewCore(webViewCore) { } @@ -51,16 +57,34 @@ void DeviceOrientationManager::setMockOrientation(PassRefPtr<DeviceOrientation> static_cast<DeviceOrientationClientMock*>(client())->setOrientation(orientation); }; +void DeviceOrientationManager::onOrientationChange(PassRefPtr<DeviceOrientation> orientation) +{ + ASSERT(!m_useMock); + static_cast<DeviceOrientationClientImpl*>(m_client.get())->onOrientationChange(orientation); +} + +void DeviceOrientationManager::maybeSuspendClient() +{ + if (!m_useMock && m_client) + static_cast<DeviceOrientationClientImpl*>(m_client.get())->suspend(); +} + +void DeviceOrientationManager::maybeResumeClient() +{ + if (!m_useMock && m_client) + static_cast<DeviceOrientationClientImpl*>(m_client.get())->resume(); +} + DeviceOrientationClient* DeviceOrientationManager::client() { - // FIXME: Implement real client. if (!m_client) - m_client.set(m_useMock ? new DeviceOrientationClientMock() : 0); + m_client.set(m_useMock ? new DeviceOrientationClientMock + : static_cast<DeviceOrientationClient*>(new DeviceOrientationClientImpl(m_webViewCore))); ASSERT(m_client); return m_client.get(); } -// JNI for android.webkit.MockDeviceOrientation +// JNI for android.webkit.DeviceOrientationManager static const char* javaDeviceOrientationManagerClass = "android/webkit/DeviceOrientationManager"; static WebViewCore* getWebViewCore(JNIEnv* env, jobject webViewCoreObject) @@ -81,9 +105,16 @@ static void setMockOrientation(JNIEnv* env, jobject, jobject webViewCoreObject, getWebViewCore(env, webViewCoreObject)->deviceOrientationManager()->setMockOrientation(orientation.release()); } +static void onOrientationChange(JNIEnv* env, jobject, jobject webViewCoreObject, bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) +{ + RefPtr<DeviceOrientation> orientation = DeviceOrientation::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); + getWebViewCore(env, webViewCoreObject)->deviceOrientationManager()->onOrientationChange(orientation.release()); +} + static JNINativeMethod gDeviceOrientationManagerMethods[] = { { "nativeUseMock", "(Landroid/webkit/WebViewCore;)V", (void*) useMock }, - { "nativeSetMockOrientation", "(Landroid/webkit/WebViewCore;ZDZDZD)V", (void*) setMockOrientation } + { "nativeSetMockOrientation", "(Landroid/webkit/WebViewCore;ZDZDZD)V", (void*) setMockOrientation }, + { "nativeOnOrientationChange", "(Landroid/webkit/WebViewCore;ZDZDZD)V", (void*) onOrientationChange } }; int register_device_orientation_manager(JNIEnv* env) diff --git a/WebKit/android/jni/DeviceOrientationManager.h b/WebKit/android/jni/DeviceOrientationManager.h index 0e43c18..a0da32f 100644 --- a/WebKit/android/jni/DeviceOrientationManager.h +++ b/WebKit/android/jni/DeviceOrientationManager.h @@ -26,9 +26,11 @@ #ifndef DeviceOrientationManager_h #define DeviceOrientationManager_h +#include <DeviceOrientation.h> #include <DeviceOrientationClient.h> -#include <PassRefPtr.h> #include <OwnPtr.h> +#include <PassRefPtr.h> +#include <RefPtr.h> namespace WebCore { class DeviceOrientation; @@ -36,20 +38,26 @@ class DeviceOrientation; namespace android { -// This class handles providing a client for DeviceOrientation. This is -// non-trivial because of the need to be able to use and configure a mock -// client. This class is owned by WebViewCore and exists to keep cruft out of -// that class. +class WebViewCore; + +// This class takes care of the fact that the client used for DeviceOrientation +// may be either the real implementation or a mock. It also handles setting the +// orientation on both the real and mock clients. This class is owned by +// WebViewCore and exists to keep cruft out of that class. class DeviceOrientationManager { public: - DeviceOrientationManager(); + DeviceOrientationManager(WebViewCore*); void useMock(); void setMockOrientation(PassRefPtr<WebCore::DeviceOrientation>); + void onOrientationChange(PassRefPtr<WebCore::DeviceOrientation>); + void maybeSuspendClient(); + void maybeResumeClient(); WebCore::DeviceOrientationClient* client(); private: bool m_useMock; + WebViewCore* m_webViewCore; OwnPtr<WebCore::DeviceOrientationClient> m_client; }; diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 868233a..a868260 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -42,6 +42,7 @@ #include "DragClientAndroid.h" #include "EditorClientAndroid.h" #include "Element.h" +#include "FocusController.h" #include "Font.h" #include "FormState.h" #include "Frame.h" @@ -940,6 +941,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss // Set the frame to active to turn on keyboard focus. frame->init(); frame->selection()->setFocused(true); + frame->page()->focusController()->setFocused(true); deviceMotionC->setWebViewCore(webViewCore); deviceOrientationC->setWebViewCore(webViewCore); diff --git a/WebKit/android/jni/WebCoreJniOnLoad.cpp b/WebKit/android/jni/WebCoreJniOnLoad.cpp index 57fccac..cb3fb57 100644 --- a/WebKit/android/jni/WebCoreJniOnLoad.cpp +++ b/WebKit/android/jni/WebCoreJniOnLoad.cpp @@ -35,6 +35,7 @@ #include "DeviceOrientationClientAndroid.h" #include "DragClientAndroid.h" #include "EditorClientAndroid.h" +#include "FocusController.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameLoaderClientAndroid.h" @@ -233,6 +234,7 @@ EXPORT void benchmark(const char* url, int reloadCount, int width, int height) { // assertion in the Cache code) frame->init(); frame->selection()->setFocused(true); + frame->page()->focusController()->setFocused(true); deviceMotion->setWebViewCore(webViewCore); deviceOrientation->setWebViewCore(webViewCore); diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index f389a39..9b84409 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -48,6 +48,7 @@ #if USE(V8) #include "WorkerContextExecutionProxy.h" #endif +#include "WebRequestContext.h" #include <JNIHelp.h> #include <utils/misc.h> @@ -76,6 +77,7 @@ struct FieldIds { "Ljava/lang/String;"); mUserAgent = env->GetFieldID(clazz, "mUserAgent", "Ljava/lang/String;"); + mAcceptLanguage = env->GetFieldID(clazz, "mAcceptLanguage", "Ljava/lang/String;"); mMinimumFontSize = env->GetFieldID(clazz, "mMinimumFontSize", "I"); mMinimumLogicalFontSize = env->GetFieldID(clazz, "mMinimumLogicalFontSize", "I"); mDefaultFontSize = env->GetFieldID(clazz, "mDefaultFontSize", "I"); @@ -130,6 +132,7 @@ struct FieldIds { LOG_ASSERT(mFantasyFontFamily, "Could not find field mFantasyFontFamily"); LOG_ASSERT(mDefaultTextEncoding, "Could not find field mDefaultTextEncoding"); LOG_ASSERT(mUserAgent, "Could not find field mUserAgent"); + LOG_ASSERT(mAcceptLanguage, "Could not find field mAcceptLanguage"); LOG_ASSERT(mMinimumFontSize, "Could not find field mMinimumFontSize"); LOG_ASSERT(mMinimumLogicalFontSize, "Could not find field mMinimumLogicalFontSize"); LOG_ASSERT(mDefaultFontSize, "Could not find field mDefaultFontSize"); @@ -177,6 +180,7 @@ struct FieldIds { jfieldID mFantasyFontFamily; jfieldID mDefaultTextEncoding; jfieldID mUserAgent; + jfieldID mAcceptLanguage; jfieldID mMinimumFontSize; jfieldID mMinimumLogicalFontSize; jfieldID mDefaultFontSize; @@ -295,6 +299,11 @@ public: str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgent); WebFrame::getWebFrame(pFrame)->setUserAgent(to_string(env, str)); +#if USE(CHROME_NETWORK_STACK) + WebRequestContext::SetUserAgent(to_string(env, str)); + str = (jstring)env->GetObjectField(obj, gFieldIds->mAcceptLanguage); + WebRequestContext::SetAcceptLanguage(to_string(env, str)); +#endif jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize); s->setMinimumFontSize(size); diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 6cd1280..72b4eac 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -244,6 +244,7 @@ struct WebViewCore::JavaGlue { jmethodID m_populateVisitedLinks; jmethodID m_geolocationPermissionsShowPrompt; jmethodID m_geolocationPermissionsHidePrompt; + jmethodID m_getDeviceOrientationService; jmethodID m_addMessageToConsole; jmethodID m_getPluginClass; jmethodID m_showFullScreenPlugin; @@ -278,7 +279,8 @@ Mutex WebViewCore::gButtonMutex; Mutex WebViewCore::gCursorBoundsMutex; WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* mainframe) - : m_pluginInvalTimer(this, &WebViewCore::pluginInvalTimerFired) + : m_pluginInvalTimer(this, &WebViewCore::pluginInvalTimerFired) + , m_deviceOrientationManager(this) { m_mainFrame = mainframe; @@ -332,6 +334,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_populateVisitedLinks = GetJMethod(env, clazz, "populateVisitedLinks", "()V"); m_javaGlue->m_geolocationPermissionsShowPrompt = GetJMethod(env, clazz, "geolocationPermissionsShowPrompt", "(Ljava/lang/String;)V"); m_javaGlue->m_geolocationPermissionsHidePrompt = GetJMethod(env, clazz, "geolocationPermissionsHidePrompt", "()V"); + m_javaGlue->m_getDeviceOrientationService = GetJMethod(env, clazz, "getDeviceOrientationService", "()Landroid/webkit/DeviceOrientationService;"); m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;I)V"); m_javaGlue->m_getPluginClass = GetJMethod(env, clazz, "getPluginClass", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;"); m_javaGlue->m_showFullScreenPlugin = GetJMethod(env, clazz, "showFullScreenPlugin", "(Landroid/webkit/ViewManager$ChildView;I)V"); @@ -1846,7 +1849,6 @@ void WebViewCore::setSelection(int start, int end) client->setUiGeneratedSelectionChange(false); WebCore::Frame* focusedFrame = focus->document()->frame(); focusedFrame->revealSelection(); - setFocusControllerActive(focusedFrame, true); } String WebViewCore::modifySelection(const String& alter, const String& direction, const String& granularity) @@ -1961,7 +1963,6 @@ void WebViewCore::passToJs(int generation, const WTF::String& current, client->setUiGeneratedSelectionChange(false); m_blockTextfieldUpdates = false; m_textGeneration = generation; - setFocusControllerActive(focus->document()->frame(), true); WebCore::RenderTextControl* renderText = static_cast<WebCore::RenderTextControl*>(renderer); WTF::String test = renderText->text(); @@ -1997,18 +1998,9 @@ void WebViewCore::scrollFocusedTextInput(float xPercent, int y) renderText->setScrollTop(y); } -void WebViewCore::setFocusControllerActive(WebCore::Frame* frame, bool active) +void WebViewCore::setFocusControllerActive(bool active) { - if (!frame) { - WebCore::Node* focus = currentFocus(); - if (focus) - frame = focus->document()->frame(); - else - frame = m_mainFrame; - } - WebCore::FocusController* controller = frame->page()->focusController(); - controller->setActive(active); - controller->setFocused(active); + m_mainFrame->page()->focusController()->setActive(active); } void WebViewCore::saveDocumentState(WebCore::Frame* frame) @@ -2489,7 +2481,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node if (renderer && (renderer->isTextField() || renderer->isTextArea())) { bool ime = !(static_cast<WebCore::HTMLInputElement*>(focusNode)) ->readOnly(); - setFocusControllerActive(framePtr, ime); if (ime) { RenderTextControl* rtc = static_cast<RenderTextControl*> (renderer); @@ -2504,7 +2495,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node // keyboard and disable the focus controller because no text input // is needed. bool keyboard = focusNode->isContentEditable(); - setFocusControllerActive(framePtr, keyboard); if (keyboard) { requestKeyboard(true); } else { @@ -2513,7 +2503,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node } } else { // There is no focusNode, so the keyboard is not needed. - setFocusControllerActive(framePtr, false); clearTextEntry(); } return handled; @@ -2612,6 +2601,15 @@ void WebViewCore::geolocationPermissionsHidePrompt() checkException(env); } +jobject WebViewCore::getDeviceOrientationService() +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jobject object = env->CallObjectMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_getDeviceOrientationService); + checkException(env); + return object; +} + bool WebViewCore::jsConfirm(const WTF::String& url, const WTF::String& text) { JNIEnv* env = JSC::Bindings::getJNIEnv(); @@ -3033,7 +3031,7 @@ static void SetFocusControllerActive(JNIEnv *env, jobject obj, jboolean active) LOGV("webviewcore::nativeSetFocusControllerActive()\n"); WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(viewImpl, "viewImpl not set in nativeSetFocusControllerActive"); - viewImpl->setFocusControllerActive(0, active); + viewImpl->setFocusControllerActive(active); } static void SaveDocumentState(JNIEnv *env, jobject obj, jint frame) @@ -3384,6 +3382,8 @@ static void Pause(JNIEnv* env, jobject obj) geolocation->suspend(); } + GET_NATIVE_VIEW(env, obj)->deviceOrientationManager()->maybeSuspendClient(); + ANPEvent event; SkANP::InitEvent(&event, kLifecycle_ANPEventType); event.data.lifecycle.action = kPause_ANPLifecycleAction; @@ -3401,6 +3401,8 @@ static void Resume(JNIEnv* env, jobject obj) geolocation->resume(); } + GET_NATIVE_VIEW(env, obj)->deviceOrientationManager()->maybeResumeClient(); + ANPEvent event; SkANP::InitEvent(&event, kLifecycle_ANPEventType); event.data.lifecycle.action = kResume_ANPLifecycleAction; diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index fe29c81..11a7228 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -242,6 +242,8 @@ namespace android { */ void geolocationPermissionsHidePrompt(); + jobject getDeviceOrientationService(); + void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID, int msgLevel); /** @@ -350,7 +352,7 @@ namespace android { * Set the FocusController's active and focused states, so that * the caret will draw (true) or not. */ - void setFocusControllerActive(WebCore::Frame*, bool active); + void setFocusControllerActive(bool active); void saveDocumentState(WebCore::Frame* frame); diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index c05395c..3453d20 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -929,6 +929,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) @@ -956,6 +985,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 + @@ -971,9 +1002,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) @@ -1108,6 +1142,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; @@ -1303,6 +1338,28 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, globalOffsetX, globalOffsetY, &cachedNode.mCursorRing) == false) continue; keepTextNode: + if (nodeRenderer) { // area tags' node->renderer() == 0 + 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); + } + } else + colorIndex = 0; IntRect clip = hasClip ? bounds : absBounds; size_t clipIndex = clipTracker.size(); if (clipTracker.last().mNode == node) @@ -1347,6 +1404,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 3bf16fc..4219d66 100644 --- a/WebKit/android/nav/CachedFrame.cpp +++ b/WebKit/android/nav/CachedFrame.cpp @@ -1423,6 +1423,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 caba482..590c75d 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); } @@ -86,6 +88,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); } @@ -226,6 +231,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 dda9385..47711fd 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 2ade73b..0014e07 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; |