Add debug settings for simple line layout
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2013 17:40:06 +0000 (17:40 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2013 17:40:06 +0000 (17:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123514

Source/WebCore:

Reviewed by Andreas Kling.

* WebCore.exp.in:
* page/Settings.in:

    Add simpleLineLayoutEnabled and simpleLineLayoutDebugBordersEnabled.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseFor):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintDebugBorders):
(WebCore::SimpleLineLayout::paintFlow):

Source/WebKit2:

Reviewed by Andreas Kling.

Expose debug settings.

* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetSimpleLineLayoutEnabled):
(WKPreferencesGetSimpleLineLayoutEnabled):
(WKPreferencesSetSimpleLineLayoutDebugBordersEnabled):
(WKPreferencesGetSimpleLineLayoutDebugBordersEnabled):
* UIProcess/API/C/WKPreferencesPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/Settings.in
Source/WebCore/rendering/SimpleLineLayout.cpp
Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index adcd3a5..e9ffb38 100644 (file)
@@ -1,3 +1,21 @@
+2013-10-30  Antti Koivisto  <antti@apple.com>
+
+        Add debug settings for simple line layout
+        https://bugs.webkit.org/show_bug.cgi?id=123514
+
+        Reviewed by Andreas Kling.
+
+        * WebCore.exp.in:
+        * page/Settings.in:
+        
+            Add simpleLineLayoutEnabled and simpleLineLayoutDebugBordersEnabled.
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseFor):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::paintDebugBorders):
+        (WebCore::SimpleLineLayout::paintFlow):
+
 2013-10-30  peavo@outlook.com  <peavo@outlook.com>
 
         [Curl] Cookies are sometimes not set in download request.
index 67bb5a6..6eadffb 100644 (file)
@@ -1192,6 +1192,7 @@ __ZN7WebCore8Settings25setMinimumLogicalFontSizeEi
 __ZN7WebCore8Settings25setPrivateBrowsingEnabledEb
 __ZN7WebCore8Settings25setUserStyleSheetLocationERKNS_3URLE
 __ZN7WebCore8Settings26defaultMinDOMTimerIntervalEv
+__ZN7WebCore8Settings26setSimpleLineLayoutEnabledEb
 __ZN7WebCore8Settings27setJavaEnabledForLocalFilesEb
 __ZN7WebCore8Settings27setLoadsImagesAutomaticallyEb
 __ZN7WebCore8Settings28setDOMTimerAlignmentIntervalEd
@@ -1206,6 +1207,7 @@ __ZN7WebCore8Settings33setAggressiveTileRetentionEnabledEb
 __ZN7WebCore8Settings33setFontFallbackPrefersPictographsEb
 __ZN7WebCore8Settings37setScrollingPerformanceLoggingEnabledEb
 __ZN7WebCore8Settings38setLowPowerVideoAudioBufferSizeEnabledEb
+__ZN7WebCore8Settings38setSimpleLineLayoutDebugBordersEnabledEb
 __ZN7WebCore8Settings41setAcceleratedCompositedAnimationsEnabledEb
 __ZN7WebCore8Settings42setHiddenPageCSSAnimationSuspensionEnabledEb
 __ZN7WebCore8Settings45setShouldRespectPriorityInCSSAttributeSettersEb
index f454f65..1b8e5a8 100644 (file)
@@ -207,3 +207,6 @@ selectionIncludesAltImageText initial=true
 useLegacyBackgroundSizeShorthandBehavior initial=false
 
 minimumZoomFontSize type=float, initial=15, conditional=IOS_TEXT_AUTOSIZING
+
+simpleLineLayoutEnabled initial=true, setNeedsStyleRecalcInAllFrames=1
+simpleLineLayoutDebugBordersEnabled initial=false, setNeedsStyleRecalcInAllFrames=1
index db187cf..5dd46c4 100644 (file)
@@ -27,6 +27,7 @@
 #include "SimpleLineLayout.h"
 
 #include "FontCache.h"
+#include "Frame.h"
 #include "GraphicsContext.h"
 #include "HitTestLocation.h"
 #include "HitTestRequest.h"
@@ -38,6 +39,7 @@
 #include "RenderStyle.h"
 #include "RenderText.h"
 #include "RenderView.h"
+#include "Settings.h"
 #include "SimpleLineLayoutResolver.h"
 #include "Text.h"
 #include "TextPaintStyle.h"
@@ -59,6 +61,8 @@ bool canUseFor(const RenderBlockFlow& flow)
     // https://bugs.webkit.org/show_bug.cgi?id=123338
     return false;
 #endif
+    if (!flow.frame().settings().simpleLineLayoutEnabled())
+        return false;
     if (!flow.firstChild())
         return false;
     // This currently covers <blockflow>#text</blockflow> case.
index cabdb7f..685b089 100644 (file)
@@ -27,6 +27,7 @@
 #include "SimpleLineLayoutFunctions.h"
 
 #include "FontCache.h"
+#include "Frame.h"
 #include "GraphicsContext.h"
 #include "HitTestLocation.h"
 #include "HitTestRequest.h"
@@ -37,6 +38,7 @@
 #include "RenderBlockFlow.h"
 #include "RenderStyle.h"
 #include "RenderText.h"
+#include "Settings.h"
 #include "SimpleLineLayoutResolver.h"
 #include "Text.h"
 #include "TextPaintStyle.h"
 namespace WebCore {
 namespace SimpleLineLayout {
 
+static void paintDebugBorders(GraphicsContext& context, const LayoutRect& borderRect, const LayoutPoint& paintOffset)
+{
+    GraphicsContextStateSaver stateSaver(context);
+    context.setStrokeColor(Color(0, 255, 0), ColorSpaceDeviceRGB);
+    context.setFillColor(Color::transparent, ColorSpaceDeviceRGB);
+    IntRect rect(pixelSnappedIntRect(borderRect));
+    rect.moveBy(flooredIntPoint(paintOffset));
+    context.drawRect(rect);
+}
+
 void paintFlow(const RenderBlockFlow& flow, const Layout& layout, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     if (paintInfo.phase != PaintPhaseForeground)
@@ -52,6 +64,8 @@ void paintFlow(const RenderBlockFlow& flow, const Layout& layout, PaintInfo& pai
     RenderText& textRenderer = toRenderText(*flow.firstChild());
     ASSERT(!textRenderer.firstTextBox());
 
+    bool debugBordersEnabled = flow.frame().settings().simpleLineLayoutDebugBordersEnabled();
+
     RenderStyle& style = flow.style();
     const Font& font = style.font();
 
@@ -66,6 +80,8 @@ void paintFlow(const RenderBlockFlow& flow, const Layout& layout, PaintInfo& pai
     for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
         auto run = *it;
         context.drawText(font, TextRun(run.text()), run.baseline() + paintOffset);
+        if (debugBordersEnabled)
+            paintDebugBorders(context, run.rect(), paintOffset);
     }
 }
 
index b8a37c7..d61b80b 100644 (file)
@@ -1,3 +1,22 @@
+2013-10-30  Antti Koivisto  <antti@apple.com>
+
+        Add debug settings for simple line layout
+        https://bugs.webkit.org/show_bug.cgi?id=123514
+
+        Reviewed by Andreas Kling.
+        
+        Expose debug settings.
+
+        * Shared/WebPreferencesStore.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetSimpleLineLayoutEnabled):
+        (WKPreferencesGetSimpleLineLayoutEnabled):
+        (WKPreferencesSetSimpleLineLayoutDebugBordersEnabled):
+        (WKPreferencesGetSimpleLineLayoutDebugBordersEnabled):
+        * UIProcess/API/C/WKPreferencesPrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2013-10-30  Anders Carlsson  <andersca@apple.com>
 
         Add stubbed out WKRemoteObjectRegistry class
index db55ff0..62a0e4f 100644 (file)
@@ -165,6 +165,8 @@ namespace WebKit {
     macro(HiddenPageCSSAnimationSuspensionEnabled, hiddenPageCSSAnimationSuspensionEnabled, Bool, bool, DEFAULT_HIDDEN_PAGE_CSS_ANIMATION_SUSPENSION_ENABLED) \
     macro(LowPowerVideoAudioBufferSizeEnabled, lowPowerVideoAudioBufferSizeEnabled, Bool, bool, false) \
     macro(ThreadedScrollingEnabled, threadedScrollingEnabled, Bool, bool, true) \
+    macro(SimpleLineLayoutEnabled, simpleLineLayoutEnabled, Bool, bool, true) \
+    macro(SimpleLineLayoutDebugBordersEnabled, simpleLineLayoutDebugBordersEnabled, Bool, bool, false) \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
index df18bfe..6fcc2d6 100644 (file)
@@ -1175,3 +1175,23 @@ bool WKPreferencesGetThreadedScrollingEnabled(WKPreferencesRef preferencesRef)
 {
     return toImpl(preferencesRef)->threadedScrollingEnabled();
 }
+
+void WKPreferencesSetSimpleLineLayoutEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setSimpleLineLayoutEnabled(flag);
+}
+
+bool WKPreferencesGetSimpleLineLayoutEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->simpleLineLayoutEnabled();
+}
+
+void WKPreferencesSetSimpleLineLayoutDebugBordersEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setSimpleLineLayoutDebugBordersEnabled(flag);
+}
+
+bool WKPreferencesGetSimpleLineLayoutDebugBordersEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->simpleLineLayoutDebugBordersEnabled();
+}
index 462eb93..23e4a7c 100644 (file)
@@ -296,6 +296,14 @@ WK_EXPORT bool WKPreferencesGetThreadedScrollingEnabled(WKPreferencesRef prefere
 WK_EXPORT void WKPreferencesSetIncrementalRenderingSuppressionTimeout(WKPreferencesRef preferencesRef, double timeout);
 WK_EXPORT double WKPreferencesGetIncrementalRenderingSuppressionTimeout(WKPreferencesRef preferencesRef);
 
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetSimpleLineLayoutEnabled(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetSimpleLineLayoutEnabled(WKPreferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetSimpleLineLayoutDebugBordersEnabled(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetSimpleLineLayoutDebugBordersEnabled(WKPreferencesRef);
+
 WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef);
 
 #ifdef __cplusplus
index f7e87b6..0bbf089 100644 (file)
@@ -2453,6 +2453,8 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
 #endif
 
     settings.setLowPowerVideoAudioBufferSizeEnabled(store.getBoolValueForKey(WebPreferencesKey::lowPowerVideoAudioBufferSizeEnabledKey()));
+    settings.setSimpleLineLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::simpleLineLayoutEnabledKey()));
+    settings.setSimpleLineLayoutDebugBordersEnabled(store.getBoolValueForKey(WebPreferencesKey::simpleLineLayoutDebugBordersEnabledKey()));
 
     platformPreferencesDidChange(store);