Title: [208655] trunk
Revision
208655
Author
[email protected]
Date
2016-11-12 12:50:26 -0800 (Sat, 12 Nov 2016)

Log Message

The main content heuristic should be robust when handling large media elements
https://bugs.webkit.org/show_bug.cgi?id=164676
<rdar://problem/29211503>

Reviewed by Eric Carlson.

Source/WebCore:

Handles integer overflow gracefully when performing the main content check for very large media elements. If the
heuristic comes across such an element, it will now bail early and reject the video as main content. Also adds a
new API test: VideoControlsManager.VideoControlsManagerPageWithEnormousVideo.

* html/MediaElementSession.cpp:
(WebCore::isElementRectMostlyInMainFrame):

Tools:

Added a new test verifying that enormous video elements are handled gracefully when put through the main
content heuristic.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/enormous-video-with-sound.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208654 => 208655)


--- trunk/Source/WebCore/ChangeLog	2016-11-12 19:30:44 UTC (rev 208654)
+++ trunk/Source/WebCore/ChangeLog	2016-11-12 20:50:26 UTC (rev 208655)
@@ -1,3 +1,18 @@
+2016-11-12  Wenson Hsieh  <[email protected]>
+
+        The main content heuristic should be robust when handling large media elements
+        https://bugs.webkit.org/show_bug.cgi?id=164676
+        <rdar://problem/29211503>
+
+        Reviewed by Eric Carlson.
+
+        Handles integer overflow gracefully when performing the main content check for very large media elements. If the
+        heuristic comes across such an element, it will now bail early and reject the video as main content. Also adds a
+        new API test: VideoControlsManager.VideoControlsManagerPageWithEnormousVideo.
+
+        * html/MediaElementSession.cpp:
+        (WebCore::isElementRectMostlyInMainFrame):
+
 2016-11-12  Chris Dumez  <[email protected]>
 
         Speed up setting attributes of input elements of type 'text'

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (208654 => 208655)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2016-11-12 19:30:44 UTC (rev 208654)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2016-11-12 20:50:26 UTC (rev 208655)
@@ -698,10 +698,13 @@
 
     IntRect mainFrameRectAdjustedForScrollPosition = IntRect(-mainFrameView->documentScrollPositionRelativeToViewOrigin(), mainFrameView->contentsSize());
     IntRect elementRectInMainFrame = element.clientRect();
-    unsigned totalElementArea = elementRectInMainFrame.area().unsafeGet();
+    auto totalElementArea = elementRectInMainFrame.area<RecordOverflow>();
+    if (totalElementArea.hasOverflowed())
+        return false;
+
     elementRectInMainFrame.intersect(mainFrameRectAdjustedForScrollPosition);
 
-    return elementRectInMainFrame.area().unsafeGet() > totalElementArea / 2;
+    return elementRectInMainFrame.area().unsafeGet() > totalElementArea.unsafeGet() / 2;
 }
 
 static bool isElementLargeRelativeToMainFrame(const HTMLMediaElement& element)

Modified: trunk/Tools/ChangeLog (208654 => 208655)


--- trunk/Tools/ChangeLog	2016-11-12 19:30:44 UTC (rev 208654)
+++ trunk/Tools/ChangeLog	2016-11-12 20:50:26 UTC (rev 208655)
@@ -1,3 +1,19 @@
+2016-11-12  Wenson Hsieh  <[email protected]>
+
+        The main content heuristic should be robust when handling large media elements
+        https://bugs.webkit.org/show_bug.cgi?id=164676
+        <rdar://problem/29211503>
+
+        Reviewed by Eric Carlson.
+
+        Added a new test verifying that enormous video elements are handled gracefully when put through the main
+        content heuristic.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/enormous-video-with-sound.html: Added.
+
 2016-11-12  Dan Bernstein  <[email protected]>
 
         run-safari does not work for open source contributors

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (208654 => 208655)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-11-12 19:30:44 UTC (rev 208654)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2016-11-12 20:50:26 UTC (rev 208655)
@@ -505,6 +505,7 @@
 		E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
 		F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
 		F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
+		F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
 		F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
 		F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
 		F4F405BD1D4C0D1C007A9707 /* skinny-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */; };
@@ -577,6 +578,7 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */,
 				8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */,
 				AD57AC221DA7466E00FF1BDE /* many-iframes.html in Copy Resources */,
 				F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */,
@@ -1246,6 +1248,7 @@
 		F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		F415086C1DA040C10044BE9B /* play-audio-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "play-audio-on-click.html"; sourceTree = "<group>"; };
 		F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "large-input-field-focus-onload.html"; path = "Tests/WebKit2Cocoa/large-input-field-focus-onload.html"; sourceTree = SOURCE_ROOT; };
+		F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
 		F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
 		F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-size-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
 		F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "skinny-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
@@ -1549,6 +1552,7 @@
 		A16F66B81C40E9E100BD4D24 /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */,
 				F415086C1DA040C10044BE9B /* play-audio-on-click.html */,
 				F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */,
 				2E9896141D8F092B00739892 /* text-and-password-inputs.html */,

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (208654 => 208655)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2016-11-12 19:30:44 UTC (rev 208654)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2016-11-12 20:50:26 UTC (rev 208655)
@@ -446,6 +446,14 @@
     [webView expectControlsManager:NO afterReceivingMessage:@"playing"];
 }
 
+TEST(VideoControlsManager, VideoControlsManagerPageWithEnormousVideo)
+{
+    RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500));
+
+    [webView loadTestPageNamed:@"enormous-video-with-sound"];
+    [webView expectControlsManager:NO afterReceivingMessage:@"playing"];
+}
+
 } // namespace TestWebKitAPI
 
 #endif // WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/enormous-video-with-sound.html (0 => 208655)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/enormous-video-with-sound.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/enormous-video-with-sound.html	2016-11-12 20:50:26 UTC (rev 208655)
@@ -0,0 +1,15 @@
+<html>
+<head>
+<script>
+    function handlePlaying() {
+        try {
+            window.webkit.messageHandlers.testHandler.postMessage("playing");
+        } catch(e) {
+        }
+    }
+</script>
+</head>
+<body>
+    <video autoplay src="" width=65536 height=65536 _onplaying_=handlePlaying()></video>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to