diff options
author | Michael Kolb <kolby@google.com> | 2011-11-11 09:13:46 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-11 09:13:47 -0800 |
commit | 0de683c1b300c8e788c178c63b7dc71189c0a3d8 (patch) | |
tree | 082da772115ed12b58f2633d23145904e9ad7944 /Source | |
parent | f51315051fbfa03d02d8c098ae70e9eb227d4200 (diff) | |
parent | a742a8f1f62517167248dfc0186ee0b845146f56 (diff) | |
download | external_webkit-0de683c1b300c8e788c178c63b7dc71189c0a3d8.zip external_webkit-0de683c1b300c8e788c178c63b7dc71189c0a3d8.tar.gz external_webkit-0de683c1b300c8e788c178c63b7dc71189c0a3d8.tar.bz2 |
Merge "Fix combobox metrics and asset scaling" into ics-mr1
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/platform/android/RenderThemeAndroid.cpp | 1 | ||||
-rw-r--r-- | Source/WebKit/android/RenderSkinCombo.cpp | 55 | ||||
-rw-r--r-- | Source/WebKit/android/RenderSkinCombo.h | 1 |
3 files changed, 40 insertions, 17 deletions
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp index 481ecbf..93c99a4 100644 --- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp @@ -428,6 +428,7 @@ static void adjustMenuListStyleCommon(RenderStyle* style) style->setPaddingTop(Length(RenderSkinCombo::padding(), Fixed)); style->setPaddingBottom(Length(RenderSkinCombo::padding(), Fixed)); style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed)); + style->setMinHeight(Length(RenderSkinCombo::minHeight(), Fixed)); } void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const diff --git a/Source/WebKit/android/RenderSkinCombo.cpp b/Source/WebKit/android/RenderSkinCombo.cpp index 970e093..1711cfa 100644 --- a/Source/WebKit/android/RenderSkinCombo.cpp +++ b/Source/WebKit/android/RenderSkinCombo.cpp @@ -58,14 +58,14 @@ enum BorderStyle { // width on all sides, except on the right when it's significantly // wider to allow for the arrow. const int RenderSkinCombo::arrowMargin[ResolutionCount] = { - 22, // Medium resolution - 34, // High resolution - 46 // Extra high resolution + 16, // Medium resolution + 25, // High resolution + 34 // Extra high resolution }; const int RenderSkinCombo::padMargin[ResolutionCount] = { - 2, // Medium resolution - 5, // High resolution - 6 // Extra high resolution + 1, // Medium resolution + 1, // High resolution + 1 // Extra high resolution }; namespace { @@ -76,15 +76,15 @@ namespace { // right hand border width happens to be the same as arrowMargin // defined above. const int stretchMargin[RenderSkinAndroid::ResolutionCount] = { // border width for the bottom and left of the 9-patch - 3, // Medium resolution - 5, // High resolution - 6 // Extra high resolution + 2, // Medium resolution + 2, // High resolution + 3 // Extra high resolution }; const int stretchTop[RenderSkinAndroid::ResolutionCount] = { // border width for the top of the 9-patch - 15, // Medium resolution + 16, // Medium resolution 23, // High resolution - 34 // Extra high resolution + 32 // Extra high resolution }; // Finally, if the border is defined by the CSS, we only draw the @@ -95,9 +95,16 @@ const int stretchTop[RenderSkinAndroid::ResolutionCount] = { // border width for // image is the same as stretchMargin above, but we need to know the width // of the arrow. const int arrowWidth[RenderSkinAndroid::ResolutionCount] = { - 22, // Medium resolution - 31, // High resolution - 42 // Extra high resolution + 18, // Medium resolution + 27, // High resolution + 36 // Extra high resolution +}; + +// scale factors for various resolutions +const float scaleFactor[RenderSkinAndroid::ResolutionCount] = { + 1.0f, // medium res + 1.5f, // high res + 2.0f // extra high res }; // Store the calculated 9 patch margins for each border style. @@ -109,6 +116,11 @@ bool isDecoded = false; // True if all assets were decoded } // namespace +int RenderSkinCombo::minHeight() { + return SkScalarRound(stretchTop[RenderSkinAndroid::DrawableResolution()] + / scaleFactor[RenderSkinAndroid::DrawableResolution()]); +} + void RenderSkinCombo::Decode() { if (isDecodingAttempted) @@ -135,9 +147,9 @@ void RenderSkinCombo::Decode() // Calculate 9 patch margins. SkIRect fullAssetMargin; fullAssetMargin.fLeft = stretchMargin[res]; - fullAssetMargin.fTop = stretchTop[res]; + fullAssetMargin.fTop = stretchMargin[res]; fullAssetMargin.fRight = arrowMargin[res] + stretchMargin[res]; - fullAssetMargin.fBottom = stretchMargin[res]; + fullAssetMargin.fBottom = stretchTop[res]; SkIRect noBorderMargin; noBorderMargin.fLeft = 0; @@ -157,8 +169,9 @@ bool RenderSkinCombo::Draw(SkCanvas* canvas, Node* element, int x, int y, int wi if (!isDecoded) return true; + int resolution = RenderSkinAndroid::DrawableResolution(); State state = (element->isElementNode() && static_cast<Element*>(element)->isEnabledFormControl()) ? kNormal : kDisabled; - height = std::max(height, (stretchMargin[RenderSkinAndroid::DrawableResolution()]<<1) + 1); + height = std::max(height, (stretchMargin[resolution] * 2)); SkRect bounds; BorderStyle drawBorder = FullAsset; @@ -185,7 +198,15 @@ bool RenderSkinCombo::Draw(SkCanvas* canvas, Node* element, int x, int y, int wi bounds.fBottom -= SkIntToScalar(style->borderBottomWidth()); drawBorder = NoBorder; } + float scale = scaleFactor[resolution]; + bounds.fLeft = bounds.fLeft * scale; + bounds.fRight = bounds.fRight * scale; + bounds.fTop = bounds.fTop * scale; + bounds.fBottom = bounds.fBottom * scale; + int count = canvas->save(); + canvas->scale(1.0f / scale, 1.0f / scale); SkNinePatch::DrawNine(canvas, bounds, bitmaps[state][drawBorder], margin[drawBorder]); + canvas->restoreToCount(count); return false; } diff --git a/Source/WebKit/android/RenderSkinCombo.h b/Source/WebKit/android/RenderSkinCombo.h index 4814199..a11faac 100644 --- a/Source/WebKit/android/RenderSkinCombo.h +++ b/Source/WebKit/android/RenderSkinCombo.h @@ -48,6 +48,7 @@ public: // The image is wider than the RenderObject, so this accounts for that. static int extraWidth() { return arrowMargin[RenderSkinAndroid::DrawableResolution()]; } + static int minHeight(); static int padding() { return padMargin[RenderSkinAndroid::DrawableResolution()]; } |