Commit ea63abe7 authored by antti@apple.com's avatar antti@apple.com

Shadow DOM removal: Get rid of ContentSelectorQuery

https://bugs.webkit.org/show_bug.cgi?id=115533

Reviewed by Anders Carlsson.

This is only used for Shadow DOM distribution. <details> element works fine without it.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::distributeSelectionsTo):
* html/shadow/ContentSelectorQuery.cpp: Removed.
* html/shadow/ContentSelectorQuery.h: Removed.
* html/shadow/HTMLContentElement.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 24081c5a
......@@ -1565,7 +1565,6 @@ set(WebCore_SOURCES
html/shadow/ClearButtonElement.cpp
html/shadow/ContentDistributor.cpp
html/shadow/ContentSelectorQuery.cpp
html/shadow/DateTimeEditElement.cpp
html/shadow/DateTimeFieldElement.cpp
html/shadow/DateTimeFieldElements.cpp
......
2013-05-02 Antti Koivisto <antti@apple.com>
Shadow DOM removal: Get rid of ContentSelectorQuery
https://bugs.webkit.org/show_bug.cgi?id=115533
Reviewed by Anders Carlsson.
This is only used for Shadow DOM distribution. <details> element works fine without it.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::distributeSelectionsTo):
* html/shadow/ContentSelectorQuery.cpp: Removed.
* html/shadow/ContentSelectorQuery.h: Removed.
* html/shadow/HTMLContentElement.cpp:
2013-05-02 Arnaud Renevier <a.renevier@sisa.samsung.com>
border-radius clipping a canvas does not always clip
......
......@@ -3725,8 +3725,6 @@ webcore_sources += \
Source/WebCore/html/shadow/ClearButtonElement.h \
Source/WebCore/html/shadow/ContentDistributor.cpp \
Source/WebCore/html/shadow/ContentDistributor.h \
Source/WebCore/html/shadow/ContentSelectorQuery.cpp \
Source/WebCore/html/shadow/ContentSelectorQuery.h \
Source/WebCore/html/shadow/DateTimeEditElement.cpp \
Source/WebCore/html/shadow/DateTimeEditElement.h \
Source/WebCore/html/shadow/DateTimeFieldElement.cpp \
......
......@@ -761,7 +761,6 @@ SOURCES += \
html/parser/XSSAuditorDelegate.cpp \
html/shadow/ClearButtonElement.cpp \
html/shadow/ContentDistributor.cpp \
html/shadow/ContentSelectorQuery.cpp \
html/shadow/DateTimeEditElement.cpp \
html/shadow/DateTimeFieldElement.cpp \
html/shadow/DateTimeFieldElements.cpp \
......@@ -1950,7 +1949,6 @@ HEADERS += \
html/parser/XSSAuditor.h \
html/parser/XSSAuditorDelegate.h \
html/shadow/ContentDistributor.h \
html/shadow/ContentSelectorQuery.h \
html/shadow/HTMLContentElement.h \
html/shadow/HTMLShadowElement.h \
html/shadow/MediaControlElementTypes.h \
......
......@@ -65485,14 +65485,6 @@
RelativePath="..\html\shadow\ContentDistributor.h"
>
</File>
<File
RelativePath="..\html\shadow\ContentSelectorQuery.cpp"
>
</File>
<File
RelativePath="..\html\shadow\ContentSelectorQuery.h"
>
</File>
<File
RelativePath="..\html\shadow\DateTimeEditElement.cpp"
>
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugSuffix|Win32">
......@@ -9041,7 +9041,6 @@
<ClCompile Include="..\html\parser\XSSAuditorDelegate.cpp" />
<ClCompile Include="..\html\shadow\ClearButtonElement.cpp" />
<ClCompile Include="..\html\shadow\ContentDistributor.cpp" />
<ClCompile Include="..\html\shadow\ContentSelectorQuery.cpp" />
<ClCompile Include="..\html\shadow\DateTimeEditElement.cpp" />
<ClCompile Include="..\html\shadow\DateTimeFieldElement.cpp" />
<ClCompile Include="..\html\shadow\DateTimeFieldElements.cpp" />
......@@ -12872,7 +12871,6 @@
<ClInclude Include="..\html\parser\XSSAuditorDelegate.h" />
<ClInclude Include="..\html\shadow\ClearButtonElement.h" />
<ClInclude Include="..\html\shadow\ContentDistributor.h" />
<ClInclude Include="..\html\shadow\ContentSelectorQuery.h" />
<ClInclude Include="..\html\shadow\DateTimeEditElement.h" />
<ClInclude Include="..\html\shadow\DateTimeFieldElement.h" />
<ClInclude Include="..\html\shadow\DateTimeFieldElements.h" />
......@@ -4329,9 +4329,6 @@
<ClCompile Include="..\html\shadow\ContentDistributor.cpp">
<Filter>html\shadow</Filter>
</ClCompile>
<ClCompile Include="..\html\shadow\ContentSelectorQuery.cpp">
<Filter>html\shadow</Filter>
</ClCompile>
<ClCompile Include="..\html\shadow\DateTimeEditElement.cpp">
<Filter>html\shadow</Filter>
</ClCompile>
......@@ -11277,9 +11274,6 @@
<ClInclude Include="..\html\shadow\ContentDistributor.h">
<Filter>html\shadow</Filter>
</ClInclude>
<ClInclude Include="..\html\shadow\ContentSelectorQuery.h">
<Filter>html\shadow</Filter>
</ClInclude>
<ClInclude Include="..\html\shadow\DateTimeEditElement.h">
<Filter>html\shadow</Filter>
</ClInclude>
......
......@@ -1668,8 +1668,6 @@
578DA20F1520EBA3006141C1 /* InspectorTypeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 573D134614CE39FF0057ABCA /* InspectorTypeBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
57B791A314C6A62900F202D1 /* ContentDistributor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */; };
57B791A414C6A62900F202D1 /* ContentDistributor.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A014C6A62900F202D1 /* ContentDistributor.h */; };
57B791A514C6A62900F202D1 /* ContentSelectorQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */; };
57B791A614C6A62900F202D1 /* ContentSelectorQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */; };
57B791A914C6A63300F202D1 /* HTMLContentElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B791A714C6A63300F202D1 /* HTMLContentElement.cpp */; };
57B791AA14C6A63300F202D1 /* HTMLContentElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A814C6A63300F202D1 /* HTMLContentElement.h */; };
57CF497414EE36D700ECFF14 /* InsertionPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57CF497214EE36D700ECFF14 /* InsertionPoint.cpp */; };
......@@ -8079,8 +8077,6 @@
573D134614CE39FF0057ABCA /* InspectorTypeBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorTypeBuilder.h; sourceTree = "<group>"; };
57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentDistributor.cpp; sourceTree = "<group>"; };
57B791A014C6A62900F202D1 /* ContentDistributor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentDistributor.h; sourceTree = "<group>"; };
57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentSelectorQuery.cpp; sourceTree = "<group>"; };
57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentSelectorQuery.h; sourceTree = "<group>"; };
57B791A714C6A63300F202D1 /* HTMLContentElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLContentElement.cpp; sourceTree = "<group>"; };
57B791A814C6A63300F202D1 /* HTMLContentElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLContentElement.h; sourceTree = "<group>"; };
57CF497214EE36D700ECFF14 /* InsertionPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InsertionPoint.cpp; sourceTree = "<group>"; };
......@@ -13925,8 +13921,6 @@
C37DF8EE16E746710079A0EB /* ClearButtonElement.h */,
57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */,
57B791A014C6A62900F202D1 /* ContentDistributor.h */,
57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */,
57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */,
45861C7516194A7400010F3A /* DateTimeEditElement.cpp */,
45861C7616194A7400010F3A /* DateTimeEditElement.h */,
45861C7716194A7400010F3A /* DateTimeFieldElement.cpp */,
......@@ -21212,7 +21206,6 @@
2919A1E916B3376600787213 /* ContentFilter.h in Headers */,
59102FBC14327D3B003C9D04 /* ContentSearchUtils.h in Headers */,
97C471DC12F925BD0086354B /* ContentSecurityPolicy.h in Headers */,
57B791A614C6A62900F202D1 /* ContentSelectorQuery.h in Headers */,
41D015CA0F4B5C71004A662F /* ContentType.h in Headers */,
97627B8E14FB3CEE002CDCA1 /* ContextDestructionObserver.h in Headers */,
A7D3CA11157DF8E900860A97 /* ContextFeatures.h in Headers */,
......@@ -24638,7 +24631,6 @@
2919A1EB16B3378900787213 /* ContentFilterMac.mm in Sources */,
59102FBB14327D3B003C9D04 /* ContentSearchUtils.cpp in Sources */,
97C471DB12F925BD0086354B /* ContentSecurityPolicy.cpp in Sources */,
57B791A514C6A62900F202D1 /* ContentSelectorQuery.cpp in Sources */,
41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */,
97627B8D14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp in Sources */,
A7D3CA10157DF8E900860A97 /* ContextFeatures.cpp in Sources */,
......@@ -27,7 +27,6 @@
#include "config.h"
#include "ContentDistributor.h"
#include "ContentSelectorQuery.h"
#include "ElementShadow.h"
#include "HTMLContentElement.h"
#include "HTMLShadowElement.h"
......@@ -302,13 +301,12 @@ bool ContentDistributor::invalidate(Element* host)
void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, const ContentDistribution& pool, Vector<bool>& distributed)
{
ContentDistribution distribution;
ContentSelectorQuery query(insertionPoint);
for (size_t i = 0; i < pool.size(); ++i) {
if (distributed[i])
continue;
if (!query.matches(pool.nodes(), i))
if (insertionPoint->matchTypeFor(pool.nodes().at(i).get()) != InsertionPoint::AlwaysMatches)
continue;
Node* child = pool.at(i).get();
......
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ContentSelectorQuery.h"
#include "CSSSelectorList.h"
#include "InsertionPoint.h"
#include "SelectorChecker.h"
#include "ShadowRoot.h"
namespace WebCore {
bool ContentSelectorDataList::checkContentSelector(const CSSSelector* selector, const Vector<RefPtr<Node> >& siblings, int nth)
{
Element* element = toElement(siblings[nth].get());
SelectorChecker selectorChecker(element->document(), SelectorChecker::CollectingRules);
SelectorChecker::SelectorCheckingContext context(selector, element, SelectorChecker::VisitedMatchEnabled);
PseudoId ignoreDynamicPseudo = NOPSEUDO;
return selectorChecker.match(context, ignoreDynamicPseudo) == SelectorChecker::SelectorMatches;
}
void ContentSelectorDataList::initialize(const CSSSelectorList& selectors)
{
for (const CSSSelector* selector = selectors.first(); selector; selector = CSSSelectorList::next(selector))
m_selectors.append(selector);
}
bool ContentSelectorDataList::matches(const Vector<RefPtr<Node> >& siblings, int nth) const
{
unsigned selectorCount = m_selectors.size();
for (unsigned i = 0; i < selectorCount; ++i) {
if (checkContentSelector(m_selectors[i], siblings, nth))
return true;
}
return false;
}
ContentSelectorQuery::ContentSelectorQuery(InsertionPoint* insertionPoint)
: m_insertionPoint(insertionPoint)
{
m_selectors.initialize(insertionPoint->selectorList());
}
bool ContentSelectorQuery::matches(const Vector<RefPtr<Node> >& siblings, int nth) const
{
Node* node = siblings[nth].get();
ASSERT(node);
switch (m_insertionPoint->matchTypeFor(node)) {
case InsertionPoint::AlwaysMatches:
return true;
case InsertionPoint::NeverMatches:
return false;
case InsertionPoint::HasToMatchSelector:
return node->isElementNode() && m_selectors.matches(siblings, nth);
default:
ASSERT_NOT_REACHED();
return false;
}
}
}
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ContentSelectorQuery_h
#define ContentSelectorQuery_h
#include "CSSSelectorList.h"
#include "SelectorChecker.h"
#include "SelectorQuery.h"
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebCore {
class Document;
class Node;
class InsertionPoint;
class ContentSelectorDataList {
public:
void initialize(const CSSSelectorList&);
bool matches(const Vector<RefPtr<Node> >& siblings, int nthNode) const;
private:
static bool checkContentSelector(const CSSSelector*, const Vector<RefPtr<Node> >& siblings, int nthNode);
Vector<const CSSSelector*> m_selectors;
};
class ContentSelectorQuery {
WTF_MAKE_NONCOPYABLE(ContentSelectorQuery);
public:
explicit ContentSelectorQuery(InsertionPoint*);
bool matches(const Vector<RefPtr<Node> >& siblings, int nthNode) const;
private:
InsertionPoint* m_insertionPoint;
ContentSelectorDataList m_selectors;
};
}
#endif
......@@ -29,7 +29,6 @@
#include "CSSParser.h"
#include "ContentDistributor.h"
#include "ContentSelectorQuery.h"
#include "HTMLNames.h"
#include "QualifiedName.h"
#include "RuntimeEnabledFeatures.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment