-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-close any open BMC/BDC when ending text (bug 1898053) #18151
Open
calixteman
wants to merge
1
commit into
mozilla:master
Choose a base branch
from
calixteman:bug1898053
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1732,6 +1732,7 @@ class PartialEvaluator { | |||||||||||||||||||
const stateManager = new StateManager(initialState); | ||||||||||||||||||||
const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); | ||||||||||||||||||||
const timeSlotManager = new TimeSlotManager(); | ||||||||||||||||||||
let markedContentLevel = 0; | ||||||||||||||||||||
|
||||||||||||||||||||
function closePendingRestoreOPS(argument) { | ||||||||||||||||||||
for (let i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) { | ||||||||||||||||||||
|
@@ -1753,7 +1754,7 @@ class PartialEvaluator { | |||||||||||||||||||
timeSlotManager.reset(); | ||||||||||||||||||||
|
||||||||||||||||||||
const operation = {}; | ||||||||||||||||||||
let stop, i, ii, cs, name, isValidName; | ||||||||||||||||||||
let stop, cs, name, isValidName; | ||||||||||||||||||||
while (!(stop = timeSlotManager.check())) { | ||||||||||||||||||||
// The arguments parsed by read() are used beyond this loop, so we | ||||||||||||||||||||
// cannot reuse the same array on each iteration. Therefore we pass | ||||||||||||||||||||
|
@@ -1914,6 +1915,12 @@ class PartialEvaluator { | |||||||||||||||||||
break; | ||||||||||||||||||||
case OPS.endText: | ||||||||||||||||||||
parsingText = false; | ||||||||||||||||||||
if (markedContentLevel !== 0) { | ||||||||||||||||||||
for (let i = 0; i < markedContentLevel; i++) { | ||||||||||||||||||||
operatorList.addOp(OPS.endMarkedContent, []); | ||||||||||||||||||||
} | ||||||||||||||||||||
markedContentLevel = 0; | ||||||||||||||||||||
} | ||||||||||||||||||||
break; | ||||||||||||||||||||
case OPS.endInlineImage: | ||||||||||||||||||||
var cacheKey = args[0].cacheKey; | ||||||||||||||||||||
|
@@ -2227,6 +2234,7 @@ class PartialEvaluator { | |||||||||||||||||||
// but doing so is meaningless without knowing the semantics. | ||||||||||||||||||||
continue; | ||||||||||||||||||||
case OPS.beginMarkedContentProps: | ||||||||||||||||||||
markedContentLevel++; | ||||||||||||||||||||
if (!(args[0] instanceof Name)) { | ||||||||||||||||||||
warn(`Expected name for beginMarkedContentProps arg0=${args[0]}`); | ||||||||||||||||||||
operatorList.addOp(OPS.beginMarkedContentProps, ["OC", null]); | ||||||||||||||||||||
|
@@ -2269,21 +2277,26 @@ class PartialEvaluator { | |||||||||||||||||||
|
||||||||||||||||||||
break; | ||||||||||||||||||||
case OPS.beginMarkedContent: | ||||||||||||||||||||
markedContentLevel++; | ||||||||||||||||||||
if (args?.some(arg => arg instanceof Dict)) { | ||||||||||||||||||||
warn(`getOperatorList - ignoring operator: ${fn}`); | ||||||||||||||||||||
continue; | ||||||||||||||||||||
} | ||||||||||||||||||||
break; | ||||||||||||||||||||
case OPS.endMarkedContent: | ||||||||||||||||||||
markedContentLevel--; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to protect against this becoming negative, note Lines 3426 to 3434 in b7b8e5e
|
||||||||||||||||||||
if (args?.some(arg => arg instanceof Dict)) { | ||||||||||||||||||||
warn(`getOperatorList - ignoring operator: ${fn}`); | ||||||||||||||||||||
continue; | ||||||||||||||||||||
} | ||||||||||||||||||||
break; | ||||||||||||||||||||
default: | ||||||||||||||||||||
// Note: Ignore the operator if it has `Dict` arguments, since | ||||||||||||||||||||
// those are non-serializable, otherwise postMessage will throw | ||||||||||||||||||||
// "An object could not be cloned.". | ||||||||||||||||||||
if (args !== null) { | ||||||||||||||||||||
for (i = 0, ii = args.length; i < ii; i++) { | ||||||||||||||||||||
if (args[i] instanceof Dict) { | ||||||||||||||||||||
break; | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
if (i < ii) { | ||||||||||||||||||||
warn("getOperatorList - ignoring operator: " + fn); | ||||||||||||||||||||
continue; | ||||||||||||||||||||
} | ||||||||||||||||||||
if (args?.some(arg => arg instanceof Dict)) { | ||||||||||||||||||||
warn(`getOperatorList - ignoring operator: ${fn}`); | ||||||||||||||||||||
continue; | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
operatorList.addOp(fn, args); | ||||||||||||||||||||
|
@@ -3142,6 +3155,19 @@ class PartialEvaluator { | |||||||||||||||||||
textState.textMatrix = IDENTITY_MATRIX.slice(); | ||||||||||||||||||||
textState.textLineMatrix = IDENTITY_MATRIX.slice(); | ||||||||||||||||||||
break; | ||||||||||||||||||||
case OPS.endText: | ||||||||||||||||||||
if (includeMarkedContent) { | ||||||||||||||||||||
if (markedContentData.level !== 0) { | ||||||||||||||||||||
flushTextContentItem(); | ||||||||||||||||||||
for (let i = 0; i < markedContentData.level; i++) { | ||||||||||||||||||||
textContent.items.push({ | ||||||||||||||||||||
type: "endMarkedContent", | ||||||||||||||||||||
}); | ||||||||||||||||||||
} | ||||||||||||||||||||
markedContentData.level = 0; | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
break; | ||||||||||||||||||||
case OPS.showSpacedText: | ||||||||||||||||||||
if (!stateManager.state.font) { | ||||||||||||||||||||
self.ensureStateFont(stateManager.state); | ||||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,3 +649,4 @@ | |
!tracemonkey_freetext.pdf | ||
!issue17998.pdf | ||
!pdfjs_wikipedia.pdf | ||
!bug1898053_minimal.pdf |
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behaves subtly different than the code in
getTextContent
, which keeps the existing level-state when parsing /Form XObjects.Perhaps that's not actually necessary to do, but my point here is that
getOperatorList
andgetTextContent
should handle markedContent-levels in /Form XObjects the same way (whatever that way is).