Title: [108821] trunk
Revision
108821
Author
[email protected]
Date
2012-02-24 10:51:11 -0800 (Fri, 24 Feb 2012)

Log Message

[chromium] Have WebFrameImpl::selectionAsMarkup create interchange markup.
https://bugs.webkit.org/show_bug.cgi?id=77307

Patch by Peter Collingbourne <[email protected]> on 2012-02-24
Reviewed by Tony Chang.

This function is currently used to build markup in order to
print the selection, and will also be used to build markup for
the clipboard.  Without this change, the markup will refer to
(for example) nonexistent CSS classes and invalid relative
paths and therefore will not be interpreted correctly.

Chromium bug: http://crbug.com/23329

* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::selectionAsMarkup):

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/http/tests/misc/resources/chromium-selectionAsMarkup.html (0 => 108821)


--- trunk/LayoutTests/http/tests/misc/resources/chromium-selectionAsMarkup.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/resources/chromium-selectionAsMarkup.html	2012-02-24 18:51:11 UTC (rev 108821)
@@ -0,0 +1,43 @@
+<style>
+.red {
+    color: red;
+}
+</style>
+
+<p>
+<div id="selection">
+<a href="" class="red">hello</a>
+</div>
+not selection
+</p>
+
+<script>
+_onload_ = function() {
+    var range = document.createRange();
+    range.selectNodeContents(document.getElementById("selection"));
+    document.getSelection().addRange(range);
+    var sel = layoutTestController.selectionAsMarkup();
+
+    var errors = "";
+
+    if (sel.indexOf("not selection") != -1)
+        errors += "FAIL: non-selection text found\n";
+    if (sel.indexOf("color: red") == -1)
+        errors += "FAIL: style not pushed down\n";
+    if (sel.indexOf("resources/chromium-selectionAsMarkup.html") == -1)
+        errors += "FAIL: url not resolved\n";
+
+    if (errors == "")
+        document.body.innerText = "PASS";
+    else
+        document.body.innerText = errors;
+
+    layoutTestController.notifyDone();
+}
+</script>
+
+<p>
+This test makes sure that the markup used by print selection
+contains absolute urls and pushed down styles. This test depends
+on layoutTestController.
+</p>

Added: trunk/LayoutTests/platform/chromium/http/tests/misc/selectionAsMarkup-expected.txt (0 => 108821)


--- trunk/LayoutTests/platform/chromium/http/tests/misc/selectionAsMarkup-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/http/tests/misc/selectionAsMarkup-expected.txt	2012-02-24 18:51:11 UTC (rev 108821)
@@ -0,0 +1 @@
+PASS

Added: trunk/LayoutTests/platform/chromium/http/tests/misc/selectionAsMarkup.html (0 => 108821)


--- trunk/LayoutTests/platform/chromium/http/tests/misc/selectionAsMarkup.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/http/tests/misc/selectionAsMarkup.html	2012-02-24 18:51:11 UTC (rev 108821)
@@ -0,0 +1,8 @@
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+document.location.href = ""
+</script>

Modified: trunk/Source/WebKit/chromium/ChangeLog (108820 => 108821)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-02-24 18:41:13 UTC (rev 108820)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-02-24 18:51:11 UTC (rev 108821)
@@ -1,3 +1,21 @@
+2012-02-24  Peter Collingbourne  <[email protected]>
+
+        [chromium] Have WebFrameImpl::selectionAsMarkup create interchange markup.
+        https://bugs.webkit.org/show_bug.cgi?id=77307
+
+        Reviewed by Tony Chang.
+
+        This function is currently used to build markup in order to
+        print the selection, and will also be used to build markup for
+        the clipboard.  Without this change, the markup will refer to
+        (for example) nonexistent CSS classes and invalid relative
+        paths and therefore will not be interpreted correctly.
+
+        Chromium bug: http://crbug.com/23329
+
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::selectionAsMarkup):
+
 2012-02-24  Pavel Feldman  <[email protected]>
 
         Not reviewed: chromium image for inspector status bar button updated.

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (108820 => 108821)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-02-24 18:41:13 UTC (rev 108820)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-02-24 18:51:11 UTC (rev 108821)
@@ -1347,7 +1347,7 @@
     if (!range)
         return WebString();
 
-    return createMarkup(range.get(), 0);
+    return createMarkup(range.get(), 0, AnnotateForInterchange, false, ResolveNonLocalURLs);
 }
 
 void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition pos)

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (108820 => 108821)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2012-02-24 18:41:13 UTC (rev 108820)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2012-02-24 18:51:11 UTC (rev 108821)
@@ -247,6 +247,7 @@
     bindMethod("setShouldStayOnPageAfterHandlingBeforeUnload", &LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload);
     bindMethod("enableFixedLayoutMode", &LayoutTestController::enableFixedLayoutMode);
     bindMethod("setFixedLayoutSize", &LayoutTestController::setFixedLayoutSize);
+    bindMethod("selectionAsMarkup", &LayoutTestController::selectionAsMarkup);
     
     // The fallback method is called when an unknown method is invoked.
     bindFallbackMethod(&LayoutTestController::fallbackMethod);
@@ -2115,6 +2116,11 @@
     m_shell->webView()->setFixedLayoutSize(WebSize(width, height));
 }
 
+void LayoutTestController::selectionAsMarkup(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->set(m_shell->webView()->mainFrame()->selectionAsMarkup().utf8());
+}
+
 void LayoutTestController::workerThreadCount(CppVariant* result)
 {
     result->set(static_cast<int>(WebWorkerInfo::dedicatedWorkerCount()));

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (108820 => 108821)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2012-02-24 18:41:13 UTC (rev 108820)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2012-02-24 18:51:11 UTC (rev 108821)
@@ -427,6 +427,8 @@
     void enableFixedLayoutMode(const CppArgumentList&, CppVariant*);
     void setFixedLayoutSize(const CppArgumentList&, CppVariant*);
 
+    void selectionAsMarkup(const CppArgumentList&, CppVariant*);
+
 #if ENABLE(POINTER_LOCK)
     void didLosePointerLock(const CppArgumentList&, CppVariant*);
     void setPointerLockWillFailSynchronously(const CppArgumentList&, CppVariant*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to