Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ignore custom fonts applied to pseudo elements #442

Merged
merged 1 commit into from

2 participants

@mhoran
Collaborator

WebPage::setUserStylesheet prevents Web Fonts from loading when styles
are applied directly to elements, however if the styles are applied to
pseudo elements, the override does not apply. This leads to crashes on
Mac OS X, likely due to https://bugs.webkit.org/show_bug.cgi?id=61031.

Fixes #181.

@mhoran mhoran Ignore custom fonts applied to pseudo elements
WebPage::setUserStylesheet prevents Web Fonts from loading when styles
are applied directly to elements, however if the styles are applied to
pseudo elements, the override does not apply. This leads to crashes on
Mac OS X, likely due to https://bugs.webkit.org/show_bug.cgi?id=61031.
11c596f
@mhoran
Collaborator

Updated to apply to all pseudo elements, not just before and after.

@mhoran mhoran merged commit 11c596f into from
@mhoran mhoran deleted the branch
@jferris jferris commented on the diff
spec/driver_spec.rb
@@ -1326,6 +1332,38 @@ def make_the_server_go_away
SCRIPT
font_family.should == "Arial"
end
+
+ it "ignores custom fonts before an element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
@jferris Admin
jferris added a note

There's some duplication in these examples. You could extract a helper method to get the computed style; I think the only variation between the examples is the pseudo-selector (before, after, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@panozzaj panozzaj referenced this pull request
Closed

mixed charset regression #444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 2, 2013
  1. @mhoran

    Ignore custom fonts applied to pseudo elements

    mhoran authored
    WebPage::setUserStylesheet prevents Web Fonts from loading when styles
    are applied directly to elements, however if the styles are applied to
    pseudo elements, the override does not apply. This leads to crashes on
    Mac OS X, likely due to https://bugs.webkit.org/show_bug.cgi?id=61031.
This page is out of date. Refresh to see the latest.
Showing with 39 additions and 1 deletion.
  1. +38 −0 spec/driver_spec.rb
  2. +1 −1  src/WebPage.cpp
View
38 spec/driver_spec.rb
@@ -1308,10 +1308,16 @@ def make_the_server_go_away
<head>
<style type="text/css">
p { font-family: "Verdana"; }
+ p:before { font-family: "Verdana"; }
+ p:after { font-family: "Verdana"; }
+ #first-line-div:first-line { font-family: "Verdana"; }
+ #first-letter-div:first-letter { font-family: "Verdana"; }
</style>
</head>
<body>
<p id="text">Hello</p>
+ <p id="first-line-div">Hello first line.</p>
+ <p id="first-letter-div">Hello first letter.</p>
</body>
</html>
HTML
@@ -1326,6 +1332,38 @@ def make_the_server_go_away
SCRIPT
font_family.should == "Arial"
end
+
+ it "ignores custom fonts before an element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
@jferris Admin
jferris added a note

There's some duplication in these examples. You could extract a helper method to get the computed style; I think the only variation between the examples is the pseudo-selector (before, after, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ var element = document.getElementById("text");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'before').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
+
+ it "ignores custom fonts after an element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
+ var element = document.getElementById("text");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'after').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
+
+ it "ignores custom fonts applied to the first-line pseudo element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
+ var element = document.getElementById("first-line-div");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'first-line').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
+
+ it "ignores custom fonts applied to the first-letter pseudo element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
+ var element = document.getElementById("first-letter-div");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'first-letter').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
end
context "cookie-based app" do
View
2  src/WebPage.cpp
@@ -70,7 +70,7 @@ void WebPage::loadJavascript() {
}
void WebPage::setUserStylesheet() {
- QString data = QString("* { font-family: 'Arial' ! important; }").toUtf8().toBase64();
+ QString data = QString("*, :first-line, :first-letter, :before, :after { font-family: 'Arial' ! important; }").toUtf8().toBase64();
QUrl url = QUrl(QString("data:text/css;charset=utf-8;base64,") + data);
settings()->setUserStyleSheetUrl(url);
}
Something went wrong with that request. Please try again.