The setup is quite different to Servo-land, so add a comment about the different
setup.
Also, check viewport rules when flushing stylesheets. I believe that the
previous behavior is plain wrong, though I haven't taken the time to come up
with a test case.
In any case, it doesn't hurt any of both back-ends.
MozReview-Commit-ID: 46gtTkesOsr
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
We're incorrectly asserting that a sheet is applicable when we remove it from
the style set, but we'll actually cause the sheet to be not applicable just
before we remove it from the style set. (Note how nsStyleSet doesn't assert
this in RemoveStyleSheet.) Also, we were missing a corresponding assertion
in AddDocStylesSheet.
MozReview-Commit-ID: E5qwxwrA74F
--HG--
extra : rebase_source : 1915553a0aa6f45b347db34feace35802983b05a
I noticed that our current behavior in ContentRangeInserted is incorrect. Unlike
ContentInserted (where this code lived originally), ContentRangeInserted takes a
start and end element. I'm not sure if we ever take that path for new content that
needs style, but it seemed sketchy. And generally, it seems nice to just always
style new content the same way (though we still need to style NAC by the subtree
root, since it hasn't been attached to the parent yet).
For situations where there is indeed only one unstyled child, the traversal
overhead should be neglible, since we special-case the single-element in
parallel.rs to avoid calling into rayon.
Being more explicit about what we want here also makes us more robust against
the other handful of callpaths that can take us into
nsCSSFrameConstructor::{ContentRangeInserted,ContentAppended}. Currently we
can call StyleNewSubtree on an already-styled element via RecreateFramesForContent,
which triggers an assertion in the servo traversal.
MozReview-Commit-ID: DqCGh90deHH
The main renaming was generated with the following python script:
```
import sys
import re
CAMEL_CASE_REGEX = re.compile(r"(^|_|-)([A-Z])([A-Z]+)")
DISPLAY_REGEX = re.compile(r"\bNS_STYLE_DISPLAY_([^M][A-Z_]+)\b")
def to_camel_case(ident):
return re.sub(CAMEL_CASE_REGEX,
lambda m: m.group(2) + m.group(3).lower(), ident)
def constant_to_enum(constant):
return "StyleDisplay::" + to_camel_case(constant) + ("_" if constant == "NONE" else "")
def process_line(line):
return re.sub(DISPLAY_REGEX,
lambda m: constant_to_enum(m.group(1)), line)
lines = []
with open(sys.argv[1], "r") as f:
for line in f:
lines.append(process_line(line))
with open(sys.argv[1], "w") as f:
for line in lines:
f.write(line)
```
And the following shell commands:
```
find . -name '*.cpp' -exec python display.py {} \;
find . -name '*.h' -exec python display.py {} \;
```
MozReview-Commit-ID: 91xYCbLC2Vf
StylingStarted is a kind of nebulous and not-very-useful concept. The concept
that _is_ useful is whether the presshell has been initialized or not, but the
root element may not exist at that point.
So we need to make sure we that we can trigger the initial document style in both
presshell initialized _and_ ContentInserted, which has the nice effect of handling
root element reinsertions.
We also take the opportunity to make StyleDocument assert the existence of a root
element, and align the responsibility for clearing the dirty descendant bits between
document and non-document nodes.
Some things like nsDocumentViewer::SetPageMode recreate the presShell, so we
can't rely on the flags being correctly set always.
MozReview-Commit-ID: 4bxNjXGBaJt
--HG--
extra : rebase_source : f40ddb64d261778be2fd051503f7d2747f0c80e8
Eventually, we might want to use the same mechanism that Gecko uses directly,
and stop styling text nodes from Servo.
This would have the benefit of removing the "stash the change on the parent"
thing.
MozReview-Commit-ID: IOxNR05jkh
Signed-off-by: Emilio Cobos Álvarez <ecoal95@gmail.com>
Eventually, we might want to use the same mechanism that Gecko uses directly,
and stop styling text nodes from Servo.
This would have the benefit of removing the "stash the change on the parent"
thing.
MozReview-Commit-ID: IOxNR05jkh
Signed-off-by: Emilio Cobos Álvarez <ecoal95@gmail.com>
Eventually, we might want to use the same mechanism that Gecko uses directly,
and stop styling text nodes from Servo.
This would have the benefit of removing the "stash the change on the parent"
thing.
MozReview-Commit-ID: IOxNR05jkh