From 2b6feaa5f79528affc5fc8ac57ca94b2439ea6d6 Mon Sep 17 00:00:00 2001 From: Simon Montagu Date: Sun, 12 Jul 2009 06:32:48 -0700 Subject: [PATCH 01/42] Check alt text for right-to-left characters and enable bidi processing if they are found. Bug 503269, r+sr=roc --- intl/unicharutil/util/nsBidiUtils.cpp | 14 +++++++------- intl/unicharutil/util/nsBidiUtils.h | 2 +- layout/generic/nsImageFrame.cpp | 5 +++++ layout/reftests/bidi/503269-1-ref.html | 16 ++++++++++++++++ layout/reftests/bidi/503269-1.html | 16 ++++++++++++++++ layout/reftests/bidi/reftest.list | 1 + layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp | 14 ++------------ 7 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 layout/reftests/bidi/503269-1-ref.html create mode 100644 layout/reftests/bidi/503269-1.html diff --git a/intl/unicharutil/util/nsBidiUtils.cpp b/intl/unicharutil/util/nsBidiUtils.cpp index 6a5299dabb4..ab74dd85435 100644 --- a/intl/unicharutil/util/nsBidiUtils.cpp +++ b/intl/unicharutil/util/nsBidiUtils.cpp @@ -641,16 +641,16 @@ PRBool IsBidiControl(PRUint32 aChar) return (eBidiCat_CC == GetBidiCat(aChar) || ((aChar)&0xfffffe)==LRM_CHAR); } -PRBool HasRTLChars(nsAString& aString) +PRBool HasRTLChars(const nsAString& aString) { +// This is used to determine whether to enable bidi if a string has +// right-to-left characters. To simplify things, anything that could be a +// surrogate or RTL presentation form is covered just by testing >= 0xD800). +// It's fine to enable bidi in rare cases where it actually isn't needed. PRInt32 length = aString.Length(); for (PRInt32 i = 0; i < length; i++) { - if ((UCS2_CHAR_IS_BIDI(aString.CharAt(i)) ) || - ((NS_IS_HIGH_SURROGATE(aString.CharAt(i))) && - (++i < length) && - (NS_IS_LOW_SURROGATE(aString.CharAt(i))) && - (UTF32_CHAR_IS_BIDI(SURROGATE_TO_UCS4(aString.CharAt(i-1), - aString.CharAt(i)))))) { + PRUnichar ch = aString.CharAt(i); + if (ch >= 0xD800 || IS_IN_BMP_RTL_BLOCK(ch)) { return PR_TRUE; } } diff --git a/intl/unicharutil/util/nsBidiUtils.h b/intl/unicharutil/util/nsBidiUtils.h index 17befb0f247..96860b1bd70 100644 --- a/intl/unicharutil/util/nsBidiUtils.h +++ b/intl/unicharutil/util/nsBidiUtils.h @@ -214,7 +214,7 @@ typedef enum nsCharType nsCharType; * Give an nsString. * @return PR_TRUE if the string contains right-to-left characters */ - PRBool HasRTLChars(nsAString& aString); + PRBool HasRTLChars(const nsAString& aString); // -------------------------------------------------- // IBMBIDI diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 8f9ab9a10a8..0980710e983 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -944,6 +944,11 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext, const PRUnichar* str = aAltText.get(); PRInt32 strLen = aAltText.Length(); nscoord y = aRect.y; + + if (!aPresContext->BidiEnabled() && HasRTLChars(aAltText)) { + aPresContext->SetBidiEnabled(); + } + // Always show the first line, even if we have to clip it below PRBool firstLine = PR_TRUE; while ((strLen > 0) && (firstLine || (y + maxDescent) < aRect.YMost())) { diff --git a/layout/reftests/bidi/503269-1-ref.html b/layout/reftests/bidi/503269-1-ref.html new file mode 100644 index 00000000000..c9401fd854c --- /dev/null +++ b/layout/reftests/bidi/503269-1-ref.html @@ -0,0 +1,16 @@ + + + + Welcome to Flickr! + + + +
+ ‏ +
+ + diff --git a/layout/reftests/bidi/503269-1.html b/layout/reftests/bidi/503269-1.html new file mode 100644 index 00000000000..c08989e0935 --- /dev/null +++ b/layout/reftests/bidi/503269-1.html @@ -0,0 +1,16 @@ + + + + Welcome to Flickr! + + + +
+ +
+ + diff --git a/layout/reftests/bidi/reftest.list b/layout/reftests/bidi/reftest.list index 4d3697d9eb5..7e8620ea18b 100644 --- a/layout/reftests/bidi/reftest.list +++ b/layout/reftests/bidi/reftest.list @@ -41,3 +41,4 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 386339.html 386339-ref.html == 489887-1.html 489887-1-ref.html == 492231-1.html 492231-1-ref.html == 496006-1.html 496006-1-ref.html +== 503269-1.html 503269-1-ref.html diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 64d07b568e7..a199c0fa2d9 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -1351,18 +1351,8 @@ nsTreeBodyFrame::CheckTextForBidi(nsAutoString& aText) // We could check to see whether the prescontext already has bidi enabled, // but usually it won't, so it's probably faster to avoid the call to // GetPresContext() when it's not needed. - const PRUnichar* text = aText.get(); - PRUint32 length = aText.Length(); - PRUint32 i; - for (i = 0; i < length; ++i) { - PRUnichar ch = text[i]; - // To simplify things, anything that could be a surrogate or RTL - // presentation form is covered just by testing >= 0xD800). It's fine to - // enable bidi in rare cases where it actually isn't needed. - if (ch >= 0xD800 || IS_IN_BMP_RTL_BLOCK(ch)) { - PresContext()->SetBidiEnabled(); - break; - } + if (HasRTLChars(aText)) { + PresContext()->SetBidiEnabled(); } } From 597da5151644a88037a8d9864f400ab8cf542a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Sun, 12 Jul 2009 15:44:33 +0200 Subject: [PATCH 02/42] whitespace cleanup --- browser/base/content/browser.js | 44 +++++++++++---------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index e12672d775e..31347996b65 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -198,14 +198,12 @@ function UpdateBackForwardCommands(aWebNavigation) { * Click-and-Hold implementation for the Back and Forward buttons * XXXmano: should this live in toolbarbutton.xml? */ -function ClickAndHoldMouseDownCallback(aButton) -{ +function ClickAndHoldMouseDownCallback(aButton) { aButton.open = true; gClickAndHoldTimer = null; } -function ClickAndHoldMouseDown(aEvent) -{ +function ClickAndHoldMouseDown(aEvent) { /** * 1. Only left click starts the click and hold timer. * 2. Exclude the dropmarker area. This is done by excluding @@ -223,49 +221,35 @@ function ClickAndHoldMouseDown(aEvent) setTimeout(ClickAndHoldMouseDownCallback, 500, aEvent.currentTarget); } -function MayStopClickAndHoldTimer(aEvent) -{ +function MayStopClickAndHoldTimer(aEvent) { // Note passing null here is a no-op clearTimeout(gClickAndHoldTimer); } -function ClickAndHoldStopEvent(aEvent) -{ +function ClickAndHoldStopEvent(aEvent) { if (aEvent.originalTarget.localName != "menuitem" && aEvent.currentTarget.open) aEvent.stopPropagation(); } -function SetClickAndHoldHandlers() -{ - function _addClickAndHoldListenersOnElement(aElm) - { - aElm.addEventListener("mousedown", - ClickAndHoldMouseDown, - false); - aElm.addEventListener("mouseup", - MayStopClickAndHoldTimer, - false); - aElm.addEventListener("mouseout", - MayStopClickAndHoldTimer, - false); - +function SetClickAndHoldHandlers() { + function _addClickAndHoldListenersOnElement(aElm) { + aElm.addEventListener("mousedown", ClickAndHoldMouseDown, false); + aElm.addEventListener("mouseup", MayStopClickAndHoldTimer, false); + aElm.addEventListener("mouseout", MayStopClickAndHoldTimer, false); + // don't propagate onclick and oncommand events after // click-and-hold opened the drop-down menu - aElm.addEventListener("command", - ClickAndHoldStopEvent, - true); - aElm.addEventListener("click", - ClickAndHoldStopEvent, - true); + aElm.addEventListener("command", ClickAndHoldStopEvent, true); + aElm.addEventListener("click", ClickAndHoldStopEvent, true); } // Bug 414797: Clone the dropmarker's menu into both the back and // the forward buttons. var unifiedButton = document.getElementById("unified-back-forward-button"); - if (unifiedButton && !unifiedButton._clickHandlersAttached) { + if (unifiedButton && !unifiedButton._clickHandlersAttached) { var popup = document.getElementById("back-forward-dropmarker") - .firstChild.cloneNode(true); + .firstChild.cloneNode(true); var backButton = document.getElementById("back-button"); backButton.setAttribute("type", "menu-button"); backButton.appendChild(popup); From 8f7b9f466c20e60309a7c1a6701b2306778e86bd Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Sun, 12 Jul 2009 15:47:44 +0100 Subject: [PATCH 03/42] Bug 496097 - Make app handler dialog label action list. r=Maro Zehe, Neil Rashbrook --- toolkit/mozapps/handling/content/dialog.xul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/mozapps/handling/content/dialog.xul b/toolkit/mozapps/handling/content/dialog.xul index 01122019666..1fcf36181dd 100644 --- a/toolkit/mozapps/handling/content/dialog.xul +++ b/toolkit/mozapps/handling/content/dialog.xul @@ -61,7 +61,7 @@ - +