зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1721952 - Don't let nsTextFragment::IsBidi get out of sync even if the document has already enabled bidi. r=smaug
It's not a sound optimization in presence of adoption. Differential Revision: https://phabricator.services.mozilla.com/D123524
This commit is contained in:
Родитель
0ac52aa9d7
Коммит
ec922d3f90
|
@ -265,19 +265,16 @@ nsresult CharacterData::SetTextInternal(
|
|||
aOffset));
|
||||
|
||||
if (aOffset == 0 && endOffset == textLength) {
|
||||
// Replacing whole text or old text was empty. Don't bother to check for
|
||||
// bidi in this string if the document already has bidi enabled.
|
||||
// Replacing whole text or old text was empty.
|
||||
// If this is marked as "maybe modified frequently", the text should be
|
||||
// stored as char16_t since converting char* to char16_t* is expensive.
|
||||
bool ok =
|
||||
mText.SetTo(aBuffer, aLength, !document || !document->GetBidiEnabled(),
|
||||
HasFlag(NS_MAYBE_MODIFIED_FREQUENTLY));
|
||||
bool ok = mText.SetTo(aBuffer, aLength, true,
|
||||
HasFlag(NS_MAYBE_MODIFIED_FREQUENTLY));
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
} else if (aOffset == textLength) {
|
||||
// Appending to existing
|
||||
bool ok =
|
||||
mText.Append(aBuffer, aLength, !document || !document->GetBidiEnabled(),
|
||||
HasFlag(NS_MAYBE_MODIFIED_FREQUENTLY));
|
||||
// Appending to existing.
|
||||
bool ok = mText.Append(aBuffer, aLength, !mText.IsBidi(),
|
||||
HasFlag(NS_MAYBE_MODIFIED_FREQUENTLY));
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
} else {
|
||||
// Merging old and new
|
||||
|
@ -297,7 +294,7 @@ nsresult CharacterData::SetTextInternal(
|
|||
}
|
||||
if (aLength) {
|
||||
to.Append(aBuffer, aLength);
|
||||
if (!bidi && (!document || !document->GetBidiEnabled())) {
|
||||
if (!bidi) {
|
||||
bidi = HasRTLChars(Span(aBuffer, aLength));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,12 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIMutationObserver.h"
|
||||
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsError.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
|
@ -73,8 +72,7 @@ ASSERT_NODE_FLAGS_SPACE(NODE_TYPE_SPECIFIC_BITS_OFFSET + 8);
|
|||
|
||||
#undef CHARACTER_DATA_FLAG_BIT
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
class CharacterData : public nsIContent {
|
||||
public:
|
||||
|
@ -236,7 +234,6 @@ class CharacterData : public nsIContent {
|
|||
already_AddRefed<nsAtom> GetCurrentValueAtom();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif /* mozilla_dom_CharacterData_h */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/PBrowser.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/dom/CustomEvent.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<p>בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָֽרֶץ׃</p>
|
|
@ -0,0 +1,25 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<link rel="help" href='http://www.w3.org/TR/css-writing-modes-3/#text-direction'>
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1721952">
|
||||
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
|
||||
<link rel="author" href="https://mozilla.org" title="Mozilla">
|
||||
<link rel="match" href="bidi-dynamic-iframe-001-ref.html">
|
||||
<iframe srcdoc="בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָֽרֶץ׃"></iframe>
|
||||
<p id="target"></p>
|
||||
<script>
|
||||
onload = function() {
|
||||
let frame = document.querySelector("iframe");
|
||||
let target = document.getElementById("target");
|
||||
|
||||
let doc = frame.contentDocument;
|
||||
let bidiString = frame.getAttribute("srcdoc");
|
||||
let node = doc.createTextNode("");
|
||||
|
||||
doc.body.appendChild(node);
|
||||
node.appendData(bidiString);
|
||||
|
||||
target.appendChild(node);
|
||||
frame.remove();
|
||||
}
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче