mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 675579 - Part 1: Set the dir attribute on the input/textarea element when switching the text direction; r=roc
--HG-- extra : rebase_source : d149468874202df13a2ae82dd95933edff9bbc45
This commit is contained in:
parent
f1bc377867
commit
086ec07d8a
@ -392,17 +392,11 @@ nsEditor::GetDesiredSpellCheckState()
|
||||
}
|
||||
|
||||
// Check DOM state
|
||||
nsCOMPtr<nsIContent> content = GetRoot();
|
||||
nsCOMPtr<nsIContent> content = GetExposedRoot();
|
||||
if (!content) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For plaintext editors, we just want to check whether the textarea/input
|
||||
// itself is editable.
|
||||
if (content->IsRootOfNativeAnonymousSubtree()) {
|
||||
content = content->GetParent();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(content);
|
||||
if (!element) {
|
||||
return false;
|
||||
@ -5007,11 +5001,24 @@ nsEditor::GetEditorRoot()
|
||||
return GetRoot();
|
||||
}
|
||||
|
||||
Element*
|
||||
nsEditor::GetExposedRoot()
|
||||
{
|
||||
Element* rootElement = GetRoot();
|
||||
|
||||
// For plaintext editors, we need to ask the input/textarea element directly.
|
||||
if (rootElement && rootElement->IsRootOfNativeAnonymousSubtree()) {
|
||||
rootElement = rootElement->GetParent()->AsElement();
|
||||
}
|
||||
|
||||
return rootElement;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEditor::DetermineCurrentDirection()
|
||||
{
|
||||
// Get the current root direction from its frame
|
||||
dom::Element *rootElement = GetRoot();
|
||||
nsIContent* rootElement = GetExposedRoot();
|
||||
|
||||
// If we don't have an explicit direction, determine our direction
|
||||
// from the content's direction
|
||||
@ -5037,7 +5044,8 @@ NS_IMETHODIMP
|
||||
nsEditor::SwitchTextDirection()
|
||||
{
|
||||
// Get the current root direction from its frame
|
||||
dom::Element *rootElement = GetRoot();
|
||||
nsIContent* rootElement = GetExposedRoot();
|
||||
|
||||
nsresult rv = DetermineCurrentDirection();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -5063,7 +5071,8 @@ void
|
||||
nsEditor::SwitchTextDirectionTo(uint32_t aDirection)
|
||||
{
|
||||
// Get the current root direction from its frame
|
||||
dom::Element *rootElement = GetRoot();
|
||||
nsIContent* rootElement = GetExposedRoot();
|
||||
|
||||
nsresult rv = DetermineCurrentDirection();
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
|
@ -670,6 +670,10 @@ public:
|
||||
// editors
|
||||
virtual mozilla::dom::Element* GetEditorRoot();
|
||||
|
||||
// Likewise, but gets the text control element instead of the root for
|
||||
// plaintext editors
|
||||
mozilla::dom::Element* GetExposedRoot();
|
||||
|
||||
// Accessor methods to flags
|
||||
bool IsPlaintextEditor() const
|
||||
{
|
||||
|
@ -55,12 +55,14 @@ SimpleTest.waitForFocus(function() {
|
||||
"Textarea should appear correctly before switching the direction (" + initialDir + ")");
|
||||
t.focus();
|
||||
synthesizeKey("x", {accelKey: true, shiftKey: true});
|
||||
is(t.getAttribute("dir"), initialDir == "ltr" ? "rtl" : "ltr", "The dir attribute must be correctly updated");
|
||||
t.blur();
|
||||
var s2 = snapshotWindow(window);
|
||||
ok(compareSnapshots(s2, Screenshots.get(initialDir, true), true)[0],
|
||||
"Textarea should appear correctly after switching the direction (" + initialDir + ")");
|
||||
t.focus();
|
||||
synthesizeKey("x", {accelKey: true, shiftKey: true});
|
||||
is(t.getAttribute("dir"), initialDir == "ltr" ? "ltr" : "rtl", "The dir attribute must be correctly updated");
|
||||
t.blur();
|
||||
var s3 = snapshotWindow(window);
|
||||
ok(compareSnapshots(s3, Screenshots.get(initialDir, false), true)[0],
|
||||
|
Loading…
Reference in New Issue
Block a user