Title: [172755] trunk/Source/WebKit2
Revision
172755
Author
[email protected]
Date
2014-08-19 11:32:29 -0700 (Tue, 19 Aug 2014)

Log Message

Extend injected bundle node snapshotting to support forced white and black text
https://bugs.webkit.org/show_bug.cgi?id=136061

Patch by Peyton Randolph <[email protected]> on 2014-08-19
Reviewed by Beth Dakin.

* Shared/API/c/WKImage.h:
Add -ForceBlackText and -ForceWhiteText snapshotting options.
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toSnapshotOptions):
Support aforementioned text snapshotting options.
* Shared/ImageOptions.h:
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::imageForRect):
Respect text color snapshotting options by setting appropriate paint behaviors.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (172754 => 172755)


--- trunk/Source/WebKit2/ChangeLog	2014-08-19 17:36:54 UTC (rev 172754)
+++ trunk/Source/WebKit2/ChangeLog	2014-08-19 18:32:29 UTC (rev 172755)
@@ -1,3 +1,20 @@
+2014-08-19  Peyton Randolph  <[email protected]>
+
+        Extend injected bundle node snapshotting to support forced white and black text
+        https://bugs.webkit.org/show_bug.cgi?id=136061
+
+        Reviewed by Beth Dakin.
+
+        * Shared/API/c/WKImage.h:
+        Add -ForceBlackText and -ForceWhiteText snapshotting options.
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toSnapshotOptions):
+        Support aforementioned text snapshotting options.
+        * Shared/ImageOptions.h:
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::imageForRect):
+        Respect text color snapshotting options by setting appropriate paint behaviors.
+
 2014-08-18  Maciej Stachowiak  <[email protected]>
 
         Use NSURLFileTypeMappings directly instead of depending on WebKitSystemInterface wrappers for it

Modified: trunk/Source/WebKit2/Shared/API/c/WKImage.h (172754 => 172755)


--- trunk/Source/WebKit2/Shared/API/c/WKImage.h	2014-08-19 17:36:54 UTC (rev 172754)
+++ trunk/Source/WebKit2/Shared/API/c/WKImage.h	2014-08-19 18:32:29 UTC (rev 172755)
@@ -42,7 +42,9 @@
     kWKSnapshotOptionsShareable = 1 << 0,
     kWKSnapshotOptionsExcludeSelectionHighlighting = 1 << 1,
     kWKSnapshotOptionsInViewCoordinates = 1 << 2,
-    kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3
+    kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3,
+    kWKSnapshotOptionsForceBlackText = 1 << 4,
+    kWKSnapshotOptionsForceWhiteText = 1 << 5,
 };
 typedef uint32_t WKSnapshotOptions;
 

Modified: trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h (172754 => 172755)


--- trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2014-08-19 17:36:54 UTC (rev 172754)
+++ trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2014-08-19 18:32:29 UTC (rev 172755)
@@ -891,6 +891,10 @@
         snapshotOptions |= SnapshotOptionsInViewCoordinates;
     if (wkSnapshotOptions & kWKSnapshotOptionsPaintSelectionRectangle)
         snapshotOptions |= SnapshotOptionsPaintSelectionRectangle;
+    if (wkSnapshotOptions & kWKSnapshotOptionsForceBlackText)
+        snapshotOptions |= SnapshotOptionsForceBlackText;
+    if (wkSnapshotOptions & kWKSnapshotOptionsForceWhiteText)
+        snapshotOptions |= SnapshotOptionsForceWhiteText;
 
     return snapshotOptions;
 }

Modified: trunk/Source/WebKit2/Shared/ImageOptions.h (172754 => 172755)


--- trunk/Source/WebKit2/Shared/ImageOptions.h	2014-08-19 17:36:54 UTC (rev 172754)
+++ trunk/Source/WebKit2/Shared/ImageOptions.h	2014-08-19 18:32:29 UTC (rev 172755)
@@ -38,6 +38,8 @@
     SnapshotOptionsInViewCoordinates = 1 << 2,
     SnapshotOptionsPaintSelectionRectangle = 1 << 3,
     SnapshotOptionsExcludeDeviceScaleFactor = 1 << 5,
+    SnapshotOptionsForceBlackText = 1 << 6,
+    SnapshotOptionsForceWhiteText = 1 << 7,
 };
 typedef uint32_t SnapshotOptions;
 

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp (172754 => 172755)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2014-08-19 17:36:54 UTC (rev 172754)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2014-08-19 18:32:29 UTC (rev 172755)
@@ -144,7 +144,16 @@
     if (options & SnapshotOptionsExcludeSelectionHighlighting)
         shouldPaintSelection = FrameView::ExcludeSelection;
 
+    PaintBehavior paintBehavior = frameView->paintBehavior() | PaintBehaviorFlattenCompositingLayers;
+    if (options & SnapshotOptionsForceBlackText)
+        paintBehavior |= PaintBehaviorForceBlackText;
+    if (options & SnapshotOptionsForceWhiteText)
+        paintBehavior |= PaintBehaviorForceWhiteText;
+
+    PaintBehavior oldPaintBehavior = frameView->paintBehavior();
+    frameView->setPaintBehavior(paintBehavior);
     frameView->paintContentsForSnapshot(graphicsContext.get(), rect, shouldPaintSelection, FrameView::DocumentCoordinates);
+    frameView->setPaintBehavior(oldPaintBehavior);
 
     return snapshot.release();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to