Bug 1161392 - Enlarge touch area for AccessibleCaret. r=roc
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 27 May 2015 16:37:28 +0800
changeset 268032 cc1287e6504e54070cbf10cafead3eda2ed515d2
parent 268031 a3a3e00caaff770a4af22e11bb52832c725aabfb
child 268033 ad884eef34812182585545cf9f6d50778348d2cd
push id2294
push userbsmedberg@mozilla.com
push dateWed, 27 May 2015 15:05:10 +0000
reviewersroc
bugs1161392, 1021499
milestone41.0a1
Bug 1161392 - Enlarge touch area for AccessibleCaret. r=roc Porting the patch for Touch/SelectionCarets in bug 1021499 to AccessibleCaret.
layout/base/AccessibleCaret.cpp
layout/base/AccessibleCaret.h
layout/style/ua.css
--- a/layout/base/AccessibleCaret.cpp
+++ b/layout/base/AccessibleCaret.cpp
@@ -249,19 +249,20 @@ AccessibleCaret::CustomContentContainerF
   return containerFrame;
 }
 
 void
 AccessibleCaret::SetCaretElementStyle(const nsRect& aRect)
 {
   nsPoint position = CaretElementPosition(aRect);
   nsAutoString styleStr;
-  styleStr.AppendPrintf("left: %dpx; top: %dpx;",
+  styleStr.AppendPrintf("left: %dpx; top: %dpx; padding-top: %dpx;",
                         nsPresContext::AppUnitsToIntCSSPixels(position.x),
-                        nsPresContext::AppUnitsToIntCSSPixels(position.y));
+                        nsPresContext::AppUnitsToIntCSSPixels(position.y),
+                        nsPresContext::AppUnitsToIntCSSPixels(aRect.height));
 
   float zoomLevel = GetZoomLevel();
   styleStr.AppendPrintf(" width: %.2fpx; height: %.2fpx; margin-left: %.2fpx",
                         sWidth / zoomLevel,
                         sHeight / zoomLevel,
                         sMarginLeft / zoomLevel);
 
   ErrorResult rv;
--- a/layout/base/AccessibleCaret.h
+++ b/layout/base/AccessibleCaret.h
@@ -160,21 +160,21 @@ private:
   already_AddRefed<dom::Element> CreateCaretElement(nsIDocument* aDocument) const;
 
   // Inject caret element into custom content container.
   void InjectCaretElement(nsIDocument* aDocument);
 
   // Remove caret element from custom content container.
   void RemoveCaretElement(nsIDocument* aDocument);
 
-  // The bottom-center of the imaginary caret to which this AccessibleCaret is
+  // The top-center of the imaginary caret to which this AccessibleCaret is
   // attached.
   static nsPoint CaretElementPosition(const nsRect& aRect)
   {
-    return aRect.TopLeft() + nsPoint(aRect.width / 2, aRect.height);
+    return aRect.TopLeft() + nsPoint(aRect.width / 2, 0);
   }
 
   class DummyTouchListener final : public nsIDOMEventListener
   {
   public:
     NS_DECL_ISUPPORTS
     NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override
     {
--- a/layout/style/ua.css
+++ b/layout/style/ua.css
@@ -317,18 +317,20 @@ parsererror|sourcetext {
 div:-moz-native-anonymous.moz-accessiblecaret,
 div:-moz-native-anonymous.moz-accessiblecaret > div.image,
 div:-moz-native-anonymous.moz-accessiblecaret > div.bar {
   position: absolute;
   z-index: 2147483647;
 }
 
 div:-moz-native-anonymous.moz-accessiblecaret > div.image {
-  background-position: center center;
-  background-size: 100% 100%;
+  background-position: center bottom;
+  background-size: 100%;
+  background-repeat: no-repeat;
+  bottom: 0;
   width: 100%;
   height: 100%;
 
   /* Override this property in moz-custom-content-container to make dummy touch
    * listener work. */
   pointer-events: auto;
 }