Do not search text in iframes with "display:none" style
authorJinwoo Song <jinwoo7.song@samsung.com>
Sat, 3 Aug 2013 09:01:59 +0000 (18:01 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 5 Aug 2013 01:53:59 +0000 (01:53 +0000)
[Title] Do not search text in iframes with "display:none" style
[Issue#] N_SE-47308
[Problem] Text search takes too long time in below site.
         http://m.soundcloud.com/tracks/search?q=webkit
[Cause] iframes with "display"none" have many strings but they are not visible.
[Solution] Do not search iframes which do not have renderstyle.

Change-Id: Ib8a76611e4b2bef3b135b45280448e976255d8b3

Source/WebCore/page/Page.cpp

index 9f1e6c4..243e87e 100644 (file)
@@ -43,6 +43,9 @@
 #include "FrameTree.h"
 #include "FrameView.h"
 #include "HTMLElement.h"
+#if ENABLE(TIZEN_FIND_STRING)
+#include "HTMLFrameOwnerElement.h"
+#endif
 #include "HistogramSupport.h"
 #include "HistoryItem.h"
 #include "InspectorController.h"
@@ -51,6 +54,9 @@
 #include "MediaCanStartListener.h"
 #include "Navigator.h"
 #include "NetworkStateNotifier.h"
+#if ENABLE(TIZEN_FIND_STRING)
+#include "NodeRenderStyle.h"
+#endif
 #include "PageCache.h"
 #include "PageGroup.h"
 #include "PluginData.h"
@@ -539,6 +545,11 @@ void Page::findStringMatchingRanges(const String& target, FindOptions options, i
         if (frame->selection()->isRange())
             frameWithSelection = frame;
         frame = incrementFrame(frame, true, false);
+#if ENABLE(TIZEN_FIND_STRING)
+        // iframes with "display:none" style should not be searched.
+        if (frame && frame->ownerElement() && !frame->ownerElement()->renderStyle())
+            break;
+#endif
     } while (frame);
 
     if (matchRanges->isEmpty())
@@ -602,6 +613,11 @@ unsigned int Page::markAllMatchesForText(const String& target, FindOptions optio
         frame->editor()->setMarkedTextMatchesAreHighlighted(shouldHighlight);
         matches += frame->editor()->countMatchesForText(target, 0, options, limit ? (limit - matches) : 0, true, 0);
         frame = incrementFrame(frame, true, false);
+#if ENABLE(TIZEN_FIND_STRING)
+        // iframes with "display:none" style should not be searched.
+        if (frame && frame->ownerElement() && !frame->ownerElement()->renderStyle())
+            break;
+#endif
     } while (frame);
 
     return matches;
@@ -616,6 +632,11 @@ void Page::unmarkAllTextMatches()
     do {
         frame->document()->markers()->removeMarkers(DocumentMarker::TextMatch);
         frame = incrementFrame(frame, true, false);
+#if ENABLE(TIZEN_FIND_STRING)
+        // iframes with "display:none" style should not be searched.
+        if (frame && frame->ownerElement() && !frame->ownerElement()->renderStyle())
+            break;
+#endif
     } while (frame);
 }