[iOS] Enable -apple-system- styled elements to respond to system font size changes.
authormhock@apple.com <mhock@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2014 21:46:23 +0000 (21:46 +0000)
committermhock@apple.com <mhock@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 May 2014 21:46:23 +0000 (21:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133186
<rdar://problem/16583782>

Reviewed by Enrica Casucci.

Source/WebCore:
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::_contentSizeCategory):
(WebCore::RenderThemeIOS::contentSizeCategory):
(WebCore::RenderThemeIOS::setContentSizeCategory):

Source/WebKit2:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
(-[WKWebView _contentSizeCategoryDidChange:]):
(-[WKWebView _contentSizeCategory]):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::contentSizeCategoryDidChange):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::contentSizeCategoryDidChange):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169223 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index d6c6fa9..3c865b6 100644 (file)
@@ -1,3 +1,19 @@
+2014-05-22  Martin Hock  <mhock@apple.com>
+
+        [iOS] Enable -apple-system- styled elements to respond to system font size changes.
+        https://bugs.webkit.org/show_bug.cgi?id=133186
+        <rdar://problem/16583782>
+
+        Reviewed by Enrica Casucci.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * rendering/RenderThemeIOS.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::_contentSizeCategory):
+        (WebCore::RenderThemeIOS::contentSizeCategory):
+        (WebCore::RenderThemeIOS::setContentSizeCategory):
+
 2014-05-22  Jer Noble  <jer.noble@apple.com>
 
         [MSE] Stored samples are not freed when SourceBuffer is removed from MediaSource
index ee7bb85..c07d938 100644 (file)
@@ -2515,6 +2515,7 @@ __ZN7WebCore14FrameSelection52expandSelectionToStartOfWordContainingCaretSelecti
 __ZN7WebCore14FrameSelection6moveToERKNS_15VisiblePositionENS_14EUserTriggeredENS0_19CursorAlignOnScrollE
 __ZN7WebCore14FrameSelection6moveToERKNS_15VisiblePositionES3_NS_14EUserTriggeredE
 __ZN7WebCore14IconController3urlEv
+__ZN7WebCore14RenderThemeIOS22setContentSizeCategoryERKN3WTF6StringE
 __ZN7WebCore14ResourceHandle6cancelEv
 __ZN7WebCore14ResourceHandle9setClientEPNS_20ResourceHandleClientE
 __ZN7WebCore14ResourceHandleD1Ev
@@ -2627,6 +2628,7 @@ __ZN7WebCore4FontC1ERKNS_16FontPlatformDataEN3WTF10PassRefPtrINS_12FontSelectorE
 __ZN7WebCore4Icon18createIconForImageEP7CGImage
 __ZN7WebCore4Node17isContentEditableENS0_22UserSelectAllTreatmentE
 __ZN7WebCore4Node23compareDocumentPositionEPS0_
+__ZN7WebCore4Page52updateStyleForAllPagesAfterGlobalChangeInEnvironmentEv
 __ZN7WebCore5ColorC1EP7CGColor
 __ZN7WebCore5EventC1ERKN3WTF12AtomicStringEbb
 __ZN7WebCore5Frame15setTimersPausedEb
index f08f044..52b1df9 100644 (file)
                75793ED30D0CE85B007FC0AC /* DOMMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793ED00D0CE85B007FC0AC /* DOMMessageEvent.h */; };
                75793ED40D0CE85B007FC0AC /* DOMMessageEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */; };
                75793ED50D0CE85B007FC0AC /* DOMMessageEventInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */; };
+               759CB837192DA9190012BC64 /* ControlStates.h in Headers */ = {isa = PBXBuildFile; fileRef = 311C08BC18E35D6800B65615 /* ControlStates.h */; settings = {ATTRIBUTES = (Private, ); }; };
                75DCC7B818B81C8800A57128 /* SessionIDHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 75DCC7B718B81C8800A57128 /* SessionIDHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7633A72613D8B33A008501B6 /* LocaleToScriptMapping.h in Headers */ = {isa = PBXBuildFile; fileRef = 7633A72413D8B33A008501B6 /* LocaleToScriptMapping.h */; };
                7633A72713D8B33A008501B6 /* LocaleToScriptMappingDefault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7633A72513D8B33A008501B6 /* LocaleToScriptMappingDefault.cpp */; };
                BCEA4887097D93020094C9E4 /* RenderThemeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4848097D93020094C9E4 /* RenderThemeMac.h */; };
                BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCEA4849097D93020094C9E4 /* RenderThemeMac.mm */; };
                BCEA4889097D93020094C9E4 /* RenderTheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA484A097D93020094C9E4 /* RenderTheme.cpp */; };
-               BCEA488A097D93020094C9E4 /* RenderTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA484B097D93020094C9E4 /* RenderTheme.h */; };
+               BCEA488A097D93020094C9E4 /* RenderTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA484B097D93020094C9E4 /* RenderTheme.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BCEA488B097D93020094C9E4 /* RenderText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA484C097D93020094C9E4 /* RenderText.cpp */; };
                BCEA488C097D93020094C9E4 /* RenderText.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA484D097D93020094C9E4 /* RenderText.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BCEA488D097D93020094C9E4 /* RenderTextFragment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEA484E097D93020094C9E4 /* RenderTextFragment.cpp */; };
                FED13D3A0CEA934600D89466 /* EditorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D390CEA934600D89466 /* EditorIOS.mm */; };
                FED13D3D0CEA936A00D89466 /* FrameIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3B0CEA936A00D89466 /* FrameIOS.mm */; };
                FED13D400CEA939400D89466 /* IconIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3F0CEA939400D89466 /* IconIOS.mm */; };
-               FED13D520CEA949700D89466 /* RenderThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = FED13D500CEA949700D89466 /* RenderThemeIOS.h */; };
+               FED13D520CEA949700D89466 /* RenderThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = FED13D500CEA949700D89466 /* RenderThemeIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */; };
                FEDEF84116797108000E444A /* DatabaseStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDEF83F16797108000E444A /* DatabaseStrategy.cpp */; };
                FEDEF84216797108000E444A /* DatabaseStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDEF84016797108000E444A /* DatabaseStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
                                97BC6A451505F081001B74AC /* SQLResultSetRowList.h in Headers */,
                                97BC6A481505F081001B74AC /* SQLStatement.h in Headers */,
                                FE8A674816CDD19E00930BF8 /* SQLStatementBackend.h in Headers */,
+                               759CB837192DA9190012BC64 /* ControlStates.h in Headers */,
                                97BC6A491505F081001B74AC /* SQLStatementCallback.h in Headers */,
                                97BC6A4B1505F081001B74AC /* SQLStatementErrorCallback.h in Headers */,
                                97BC6A4E1505F081001B74AC /* SQLStatementSync.h in Headers */,
index c423008..1be5e7d 100644 (file)
@@ -47,6 +47,8 @@ public:
 
     static CFStringRef contentSizeCategory();
 
+    static void setContentSizeCategory(const String&);
+
 protected:
     virtual int baselinePosition(const RenderObject&) const override;
 
index 82e1d0c..644b1f2 100644 (file)
@@ -306,11 +306,24 @@ PassRefPtr<RenderTheme> RenderThemeIOS::create()
     return adoptRef(new RenderThemeIOS);
 }
 
+static String& _contentSizeCategory()
+{
+    static NeverDestroyed<String> _contentSizeCategory;
+    return _contentSizeCategory.get();
+}
+
 CFStringRef RenderThemeIOS::contentSizeCategory()
 {
+    if (!_contentSizeCategory().isNull())
+        return (__bridge CFStringRef)static_cast<NSString*>(_contentSizeCategory());
     return (CFStringRef)[[getUIApplicationClass() sharedApplication] preferredContentSizeCategory];
 }
 
+void RenderThemeIOS::setContentSizeCategory(const String& contentSizeCategory)
+{
+    _contentSizeCategory() = contentSizeCategory;
+}
+
 const Color& RenderThemeIOS::shadowColor() const
 {
     static Color color(0.0f, 0.0f, 0.0f, 0.7f);
index 7ac63f4..fb8a247 100644 (file)
@@ -1,3 +1,23 @@
+2014-05-22  Martin Hock  <mhock@apple.com>
+
+        [iOS] Enable -apple-system- styled elements to respond to system font size changes.
+        https://bugs.webkit.org/show_bug.cgi?id=133186
+        <rdar://problem/16583782>
+
+        Reviewed by Enrica Casucci.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]):
+        (-[WKWebView _contentSizeCategoryDidChange:]):
+        (-[WKWebView _contentSizeCategory]):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::contentSizeCategoryDidChange):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::contentSizeCategoryDidChange):
+
 2014-05-22  Alexey Proskuryakov  <ap@apple.com>
 
         [iOS] Add CFBundleAllowMixedLocalizations to WebContentService
index f0c7017..bac870a 100644 (file)
@@ -78,6 +78,7 @@
 #import "WebPageMessages.h"
 #import <CoreGraphics/CGFloat.h>
 #import <CoreGraphics/CGPDFDocumentPrivate.h>
+#import <UIKit/UIApplication.h>
 #import <UIKit/UIPeripheralHost_Private.h>
 #import <QuartzCore/CARenderServer.h>
 #import <QuartzCore/QuartzCorePrivate.h>
@@ -232,6 +233,8 @@ WKWebView* fromWebPageProxy(WebKit::WebPageProxy& page)
     [center addObserver:self selector:@selector(_keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];
     [center addObserver:self selector:@selector(_keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
     [center addObserver:self selector:@selector(_keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
+    [center addObserver:self selector:@selector(_contentSizeCategoryDidChange:) name:UIContentSizeCategoryDidChangeNotification object:nil];
+    _page->contentSizeCategoryDidChange([self _contentSizeCategory]);
 
     [[_configuration _contentProviderRegistry] addPage:*_page];
 #endif
@@ -1030,6 +1033,16 @@ static inline void setViewportConfigurationMinimumLayoutSize(WebKit::WebPageProx
     [self _keyboardChangedWithInfo:notification.userInfo adjustScrollView:YES];
 }
 
+- (void)_contentSizeCategoryDidChange:(NSNotification *)notification
+{
+    _page->contentSizeCategoryDidChange([self _contentSizeCategory]);
+}
+
+- (NSString *)_contentSizeCategory
+{
+    return [[UIApplication sharedApplication] preferredContentSizeCategory];
+}
+
 - (void)setAllowsBackForwardNavigationGestures:(BOOL)allowsBackForwardNavigationGestures
 {
     if (_allowsBackForwardNavigationGestures == allowsBackForwardNavigationGestures)
index fb24804..6da8d32 100644 (file)
@@ -634,6 +634,7 @@ public:
     void didNotHandleTapAsClick(const WebCore::IntPoint&);
     void viewportMetaTagWidthDidChange(float width);
     void didFinishDrawingPagesToPDF(const IPC::DataReference&);
+    void contentSizeCategoryDidChange(const String& contentSizeCategory);
 #endif
 
     const EditorState& editorState() const { return m_editorState; }
index 3088e29..1696cc0 100644 (file)
@@ -654,6 +654,11 @@ void WebPageProxy::didFinishDrawingPagesToPDF(const IPC::DataReference& pdfData)
     m_pageClient.didFinishDrawingPagesToPDF(pdfData);
 }
 
+void WebPageProxy::contentSizeCategoryDidChange(const String& contentSizeCategory)
+{
+    process().send(Messages::WebPage::ContentSizeCategoryDidChange(contentSizeCategory), m_pageID);
+}
+
 #if USE(QUICK_LOOK)
     
 void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
index 29f6afe..b223cda 100644 (file)
@@ -487,6 +487,7 @@ public:
     void updateSelectionAppearance();
 
     void dispatchAsynchronousTouchEvents(const Vector<WebTouchEvent, 1>& queue);
+    void contentSizeCategoryDidChange(const String&);
 #if ENABLE(INSPECTOR)
     void showInspectorIndication();
     void hideInspectorIndication();
index 1c1ccb0..aacb2f6 100644 (file)
@@ -78,6 +78,7 @@ messages -> WebPage LegacyReceiver {
     ApplicationWillResignActive()
     ApplicationWillEnterForeground()
     ApplicationDidBecomeActive()
+    ContentSizeCategoryDidChange(String contentSizeCategory)
 #endif
 
 #if ENABLE(REMOTE_INSPECTOR)
index f29bfbb..0ba0bef 100644 (file)
@@ -76,6 +76,7 @@
 #import <WebCore/PlatformMouseEvent.h>
 #import <WebCore/RenderBlock.h>
 #import <WebCore/RenderImage.h>
+#import <WebCore/RenderThemeIOS.h>
 #import <WebCore/RenderView.h>
 #import <WebCore/ResourceBuffer.h>
 #import <WebCore/SharedBuffer.h>
@@ -2326,6 +2327,12 @@ void WebPage::computePagesForPrintingAndStartDrawingToPDF(uint64_t frameID, cons
     send(Messages::WebPageProxy::DidFinishDrawingPagesToPDF(IPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get()))));
 }
 
+void WebPage::contentSizeCategoryDidChange(const String& contentSizeCategory)
+{
+    RenderThemeIOS::setContentSizeCategory(contentSizeCategory);
+    Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)