Bug 1385395 - Use flag bits in the nsGenericDOMDataNode to record whether nsTextFrame-related properties are present, so we don't perform unnecessary hashtable lookups in CharacterDataChanged etc. r=dbaron
This commit is contained in:
@@ -64,7 +64,6 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLineBreaker.h"
|
||||
#include "nsIWordBreaker.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
@@ -736,7 +735,9 @@ int32_t nsTextFrame::GetInFlowContentLength() {
|
||||
}
|
||||
|
||||
FlowLengthProperty* flowLength =
|
||||
static_cast<FlowLengthProperty*>(mContent->GetProperty(nsGkAtoms::flowlength));
|
||||
mContent->HasFlag(NS_HAS_FLOWLENGTH_PROPERTY)
|
||||
? static_cast<FlowLengthProperty*>(mContent->GetProperty(nsGkAtoms::flowlength))
|
||||
: nullptr;
|
||||
|
||||
/**
|
||||
* This frame must start inside the cached flow. If the flow starts at
|
||||
@@ -764,6 +765,7 @@ int32_t nsTextFrame::GetInFlowContentLength() {
|
||||
delete flowLength;
|
||||
flowLength = nullptr;
|
||||
}
|
||||
mContent->SetFlags(NS_HAS_FLOWLENGTH_PROPERTY);
|
||||
}
|
||||
if (flowLength) {
|
||||
flowLength->mStartOffset = mContentOffset;
|
||||
@@ -4380,9 +4382,13 @@ nsTextFrame::Init(nsIContent* aContent,
|
||||
|
||||
// Remove any NewlineOffsetProperty or InFlowContentLengthProperty since they
|
||||
// might be invalid if the content was modified while there was no frame
|
||||
aContent->DeleteProperty(nsGkAtoms::newline);
|
||||
if (PresContext()->BidiEnabled()) {
|
||||
if (aContent->HasFlag(NS_HAS_NEWLINE_PROPERTY)) {
|
||||
aContent->DeleteProperty(nsGkAtoms::newline);
|
||||
aContent->UnsetFlags(NS_HAS_NEWLINE_PROPERTY);
|
||||
}
|
||||
if (aContent->HasFlag(NS_HAS_FLOWLENGTH_PROPERTY)) {
|
||||
aContent->DeleteProperty(nsGkAtoms::flowlength);
|
||||
aContent->UnsetFlags(NS_HAS_FLOWLENGTH_PROPERTY);
|
||||
}
|
||||
|
||||
// Since our content has a frame now, this flag is no longer needed.
|
||||
@@ -4830,9 +4836,13 @@ nsTextFrame::DisconnectTextRuns()
|
||||
nsresult
|
||||
nsTextFrame::CharacterDataChanged(CharacterDataChangeInfo* aInfo)
|
||||
{
|
||||
mContent->DeleteProperty(nsGkAtoms::newline);
|
||||
if (PresContext()->BidiEnabled()) {
|
||||
if (mContent->HasFlag(NS_HAS_NEWLINE_PROPERTY)) {
|
||||
mContent->DeleteProperty(nsGkAtoms::newline);
|
||||
mContent->UnsetFlags(NS_HAS_NEWLINE_PROPERTY);
|
||||
}
|
||||
if (mContent->HasFlag(NS_HAS_FLOWLENGTH_PROPERTY)) {
|
||||
mContent->DeleteProperty(nsGkAtoms::flowlength);
|
||||
mContent->UnsetFlags(NS_HAS_FLOWLENGTH_PROPERTY);
|
||||
}
|
||||
|
||||
// Find the first frame whose text has changed. Frames that are entirely
|
||||
@@ -9278,7 +9288,9 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
||||
NewlineProperty* cachedNewlineOffset = nullptr;
|
||||
if (textStyle->NewlineIsSignificant(this)) {
|
||||
cachedNewlineOffset =
|
||||
static_cast<NewlineProperty*>(mContent->GetProperty(nsGkAtoms::newline));
|
||||
mContent->HasFlag(NS_HAS_NEWLINE_PROPERTY)
|
||||
? static_cast<NewlineProperty*>(mContent->GetProperty(nsGkAtoms::newline))
|
||||
: nullptr;
|
||||
if (cachedNewlineOffset && cachedNewlineOffset->mStartOffset <= offset &&
|
||||
(cachedNewlineOffset->mNewlineOffset == -1 ||
|
||||
cachedNewlineOffset->mNewlineOffset >= offset)) {
|
||||
@@ -9763,6 +9775,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
||||
delete cachedNewlineOffset;
|
||||
cachedNewlineOffset = nullptr;
|
||||
}
|
||||
mContent->SetFlags(NS_HAS_NEWLINE_PROPERTY);
|
||||
}
|
||||
if (cachedNewlineOffset) {
|
||||
cachedNewlineOffset->mStartOffset = offset;
|
||||
@@ -9770,6 +9783,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
||||
}
|
||||
} else if (cachedNewlineOffset) {
|
||||
mContent->DeleteProperty(nsGkAtoms::newline);
|
||||
mContent->UnsetFlags(NS_HAS_NEWLINE_PROPERTY);
|
||||
}
|
||||
|
||||
// Compute space and letter counts for justification, if required
|
||||
@@ -10252,7 +10266,10 @@ void
|
||||
nsTextFrame::AdjustOffsetsForBidi(int32_t aStart, int32_t aEnd)
|
||||
{
|
||||
AddStateBits(NS_FRAME_IS_BIDI);
|
||||
mContent->DeleteProperty(nsGkAtoms::flowlength);
|
||||
if (mContent->HasFlag(NS_HAS_FLOWLENGTH_PROPERTY)) {
|
||||
mContent->DeleteProperty(nsGkAtoms::flowlength);
|
||||
mContent->UnsetFlags(NS_HAS_FLOWLENGTH_PROPERTY);
|
||||
}
|
||||
|
||||
/*
|
||||
* After Bidi resolution we may need to reassign text runs.
|
||||
|
||||
Reference in New Issue
Block a user