Title: [187797] trunk
Revision
187797
Author
[email protected]
Date
2015-08-03 18:39:40 -0700 (Mon, 03 Aug 2015)

Log Message

REGRESSION(r184899): Crash when focusing an input element styled with a web font
https://bugs.webkit.org/show_bug.cgi?id=147616
<rdar://problem/21838271>

Reviewed by Dean Jackson.

Source/WebCore:

NSFontManager can't handle web fonts. We used to pass null to NSFontManager in this case,
but r184899 changed that.

Test: fast/text/input-webfont-focus.html

* platform/graphics/FontPlatformData.h:
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::activatedFont):

Source/WebKit/mac:

NSFontManager can't handle web fonts. We used to pass null to NSFontManager in this case,
but r184899 changed that.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _updateFontPanel]):

LayoutTests:

* fast/text/input-webfont-focus-expected.txt: Added.
* fast/text/input-webfont-focus.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187796 => 187797)


--- trunk/LayoutTests/ChangeLog	2015-08-04 01:27:33 UTC (rev 187796)
+++ trunk/LayoutTests/ChangeLog	2015-08-04 01:39:40 UTC (rev 187797)
@@ -1,3 +1,14 @@
+2015-08-03  Myles C. Maxfield  <[email protected]>
+
+        REGRESSION(r184899): Crash when focusing an input element styled with a web font
+        https://bugs.webkit.org/show_bug.cgi?id=147616
+        <rdar://problem/21838271>
+
+        Reviewed by Dean Jackson.
+
+        * fast/text/input-webfont-focus-expected.txt: Added.
+        * fast/text/input-webfont-focus.html: Added.
+
 2015-07-31  Filip Pizlo  <[email protected]>
 
         DFG should have adaptive structure watchpoints

Added: trunk/LayoutTests/fast/text/input-webfont-focus-expected.txt (0 => 187797)


--- trunk/LayoutTests/fast/text/input-webfont-focus-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/input-webfont-focus-expected.txt	2015-08-04 01:39:40 UTC (rev 187797)
@@ -0,0 +1,2 @@
+This test makes sure that a crash doesn't occur when focusing an input element styled with a web font. The test is successful if there is no crash.
+

Added: trunk/LayoutTests/fast/text/input-webfont-focus.html (0 => 187797)


--- trunk/LayoutTests/fast/text/input-webfont-focus.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/input-webfont-focus.html	2015-08-04 01:39:40 UTC (rev 187797)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebAhem";
+    src: url("../../resources/Ahem.ttf") format(truetype);
+}
+* {
+    font: 50px WebAhem;
+}
+</style>
+</head>
+<body>
+<div style="font: 16px serif;">This test makes sure that a crash doesn't occur when focusing an input element styled with a web font. The test is successful if there is no crash.</div>
+<input id="i" type="text" placeholder="asdf">
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+window.setTimeout(function() {
+    var inputElement = document.getElementById("i");
+    inputElement.focus();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 0);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (187796 => 187797)


--- trunk/Source/WebCore/ChangeLog	2015-08-04 01:27:33 UTC (rev 187796)
+++ trunk/Source/WebCore/ChangeLog	2015-08-04 01:39:40 UTC (rev 187797)
@@ -1,3 +1,20 @@
+2015-08-03  Myles C. Maxfield  <[email protected]>
+
+        REGRESSION(r184899): Crash when focusing an input element styled with a web font
+        https://bugs.webkit.org/show_bug.cgi?id=147616
+        <rdar://problem/21838271>
+
+        Reviewed by Dean Jackson.
+
+        NSFontManager can't handle web fonts. We used to pass null to NSFontManager in this case,
+        but r184899 changed that.
+
+        Test: fast/text/input-webfont-focus.html
+
+        * platform/graphics/FontPlatformData.h:
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::activatedFont):
+
 2015-08-03  Brent Fulgham  <[email protected]>
 
         [Win] Unreviewed build fix.

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (187796 => 187797)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2015-08-04 01:27:33 UTC (rev 187796)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2015-08-04 01:39:40 UTC (rev 187797)
@@ -108,6 +108,7 @@
     bool useGDI() const { return m_useGDI; }
 #elif PLATFORM(COCOA)
     CTFontRef font() const { return m_font.get(); }
+    WEBCORE_EXPORT CTFontRef activatedFont() const; // Returns nullptr iff the font is not activated (otherwise returns font()).
     void setFont(CTFontRef);
 
     CTFontRef ctFont() const;

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (187796 => 187797)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2015-08-04 01:27:33 UTC (rev 187796)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2015-08-04 01:39:40 UTC (rev 187797)
@@ -91,6 +91,15 @@
     return m_cgFont == other.m_cgFont;
 }
 
+CTFontRef FontPlatformData::activatedFont() const
+{
+    CTFontRef platformFont = font();
+    ASSERT(platformFont);
+    if (adoptCF(CTFontCopyAttribute(platformFont, kCTFontURLAttribute)))
+        return platformFont;
+    return nullptr;
+}
+
 void FontPlatformData::setFont(CTFontRef font)
 {
     ASSERT_ARG(font, font);

Modified: trunk/Source/WebKit/mac/ChangeLog (187796 => 187797)


--- trunk/Source/WebKit/mac/ChangeLog	2015-08-04 01:27:33 UTC (rev 187796)
+++ trunk/Source/WebKit/mac/ChangeLog	2015-08-04 01:39:40 UTC (rev 187797)
@@ -1,3 +1,17 @@
+2015-08-03  Myles C. Maxfield  <[email protected]>
+
+        REGRESSION(r184899): Crash when focusing an input element styled with a web font
+        https://bugs.webkit.org/show_bug.cgi?id=147616
+        <rdar://problem/21838271>
+
+        Reviewed by Dean Jackson.
+
+        NSFontManager can't handle web fonts. We used to pass null to NSFontManager in this case,
+        but r184899 changed that.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _updateFontPanel]):
+
 2015-07-31  Chris Dumez  <[email protected]>
 
         Drop dummy Timer callbacks

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (187796 => 187797)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2015-08-04 01:27:33 UTC (rev 187796)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2015-08-04 01:39:40 UTC (rev 187797)
@@ -5485,7 +5485,7 @@
     NSDictionary *attributes = nil;
     if (Frame* coreFrame = core([self _frame])) {
         if (const Font* fd = coreFrame->editor().fontForSelection(multipleFonts))
-            font = fd->getNSFont();
+            font = static_cast<NSFont *>(fd->platformData().activatedFont());
         attributes = coreFrame->editor().fontAttributesForSelectionStart();
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to