Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f895534

Browse files
committed
Merge pull request #162 from Hixie/focus
Remove focus support from sky/engine/core/*.
2 parents 4e6b873 + 38c8026 commit f895534

37 files changed

+6
-1052
lines changed

sky/engine/core/core.gni

-3
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,6 @@ sky_core_files = [
414414
"loader/UniqueIdentifier.cpp",
415415
"loader/UniqueIdentifier.h",
416416
"page/ChromeClient.h",
417-
"page/FocusController.cpp",
418-
"page/FocusController.h",
419-
"page/FocusType.h",
420417
"page/Page.cpp",
421418
"page/Page.h",
422419
"painting/Canvas.cpp",

sky/engine/core/css/CSSSelector.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ struct NameToPseudoStruct {
6969
// This table should be kept sorted.
7070
const static NameToPseudoStruct pseudoTypeMap[] = {
7171
{"active", CSSSelector::PseudoActive},
72-
{"focus", CSSSelector::PseudoFocus},
7372
{"host", CSSSelector::PseudoHost},
7473
{"host(", CSSSelector::PseudoHost},
7574
{"hover", CSSSelector::PseudoHover},

sky/engine/core/css/CSSSelector.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace blink {
101101
Tag, // Example: div
102102
Id, // Example: #id
103103
Class, // example: .class
104-
PseudoClass, // Example: :focus
104+
PseudoClass, // Example: :hover
105105
PseudoElement, // Example: ::first-line
106106
Exact, // Example: E[foo="bar"]
107107
Set, // Example: E[foo]
@@ -112,7 +112,6 @@ namespace blink {
112112
PseudoNotParsed = 0,
113113
PseudoUnknown,
114114
PseudoHover,
115-
PseudoFocus,
116115
PseudoActive,
117116
PseudoLang,
118117
PseudoHost,

sky/engine/core/css/ElementRuleCollector.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData)
124124
if (checker.matchedAttributeSelector())
125125
m_style->setUnique();
126126

127-
if (checker.matchedFocusSelector())
128-
m_style->setAffectedByFocus();
129-
130127
if (checker.matchedHoverSelector())
131128
m_style->setAffectedByHover();
132129

sky/engine/core/css/SelectorChecker.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,13 @@
3232
#include "sky/engine/core/dom/Document.h"
3333
#include "sky/engine/core/frame/LocalFrame.h"
3434
#include "sky/engine/core/html/parser/HTMLParserIdioms.h"
35-
#include "sky/engine/core/page/FocusController.h"
3635
#include "sky/engine/core/rendering/style/RenderStyle.h"
3736

3837
namespace blink {
3938

40-
static bool matchesFocusPseudoClass(const Element& element)
41-
{
42-
if (!element.focused())
43-
return false;
44-
LocalFrame* frame = element.document().frame();
45-
if (!frame)
46-
return false;
47-
return true;
48-
}
49-
5039
SelectorChecker::SelectorChecker(const Element& element)
5140
: m_element(element)
5241
, m_matchedAttributeSelector(false)
53-
, m_matchedFocusSelector(false)
5442
, m_matchedHoverSelector(false)
5543
, m_matchedActiveSelector(false)
5644
{
@@ -122,10 +110,6 @@ bool SelectorChecker::checkOne(const CSSSelector& selector)
122110
bool SelectorChecker::checkPseudoClass(const CSSSelector& selector)
123111
{
124112
switch (selector.pseudoType()) {
125-
case CSSSelector::PseudoFocus:
126-
m_matchedFocusSelector = true;
127-
return matchesFocusPseudoClass(m_element);
128-
129113
case CSSSelector::PseudoHover:
130114
m_matchedHoverSelector = true;
131115
return m_element.hovered();

sky/engine/core/css/SelectorChecker.h

-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class SelectorChecker {
4444
bool match(const CSSSelector&);
4545

4646
bool matchedAttributeSelector() const { return m_matchedAttributeSelector; }
47-
bool matchedFocusSelector() const { return m_matchedFocusSelector; }
4847
bool matchedHoverSelector() const { return m_matchedHoverSelector; }
4948
bool matchedActiveSelector() const { return m_matchedActiveSelector; }
5049

@@ -54,7 +53,6 @@ class SelectorChecker {
5453

5554
const Element& m_element;
5655
bool m_matchedAttributeSelector;
57-
bool m_matchedFocusSelector;
5856
bool m_matchedHoverSelector;
5957
bool m_matchedActiveSelector;
6058
};

sky/engine/core/dom/ContainerNode.cpp

-46
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ PassRefPtr<Node> ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* re
134134
if (targets.isEmpty())
135135
return newChild;
136136

137-
// Must check this again beacuse focus events might run synchronously when
138-
// removing children.
139137
checkAcceptChildHierarchy(*newChild, 0, exceptionState);
140138
if (exceptionState.had_exception())
141139
return nullptr;
@@ -252,8 +250,6 @@ PassRefPtr<Node> ContainerNode::replaceChild(PassRefPtr<Node> newChild, PassRefP
252250
if (exceptionState.had_exception())
253251
return nullptr;
254252

255-
// Must check this again beacuse focus events might run synchronously when
256-
// removing children.
257253
checkAcceptChildHierarchy(*newChild, child.get(),exceptionState);
258254
if (exceptionState.had_exception())
259255
return nullptr;
@@ -384,10 +380,6 @@ PassRefPtr<Node> ContainerNode::removeChild(PassRefPtr<Node> oldChild, Exception
384380
RefPtr<Node> protect(this);
385381
RefPtr<Node> child = oldChild;
386382

387-
document().removeFocusedElementOfSubtree(child.get());
388-
389-
// Events fired when blurring currently focused node might have moved this
390-
// child into a different parent.
391383
if (child->parentNode() != this) {
392384
exceptionState.ThrowDOMException(NotFoundError, "The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler?");
393385
return nullptr;
@@ -450,12 +442,6 @@ void ContainerNode::removeChildren()
450442
willRemoveChildren();
451443

452444
{
453-
// Exclude this node when looking for removed focusedElement since only
454-
// children will be removed.
455-
// This must be later than willRemoveChildren, which might change focus
456-
// state of a child.
457-
document().removeFocusedElementOfSubtree(this, true);
458-
459445
// Removing a node from a selection can cause widget updates.
460446
document().nodeChildrenWillBeRemoved(*this);
461447
}
@@ -512,8 +498,6 @@ PassRefPtr<Node> ContainerNode::appendChild(PassRefPtr<Node> newChild, Exception
512498
if (targets.isEmpty())
513499
return newChild;
514500

515-
// Must check this again beacuse focus events might run synchronously when
516-
// removing children.
517501
checkAcceptChildHierarchy(*newChild, 0, exceptionState);
518502
if (exceptionState.had_exception())
519503
return nullptr;
@@ -771,36 +755,6 @@ LayoutRect ContainerNode::boundingBox() const
771755
return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperLeft) - upperLeft));
772756
}
773757

774-
// This is used by FrameSelection to denote when the active-state of the page has changed
775-
// independent of the focused element changing.
776-
void ContainerNode::focusStateChanged()
777-
{
778-
// If we're just changing the window's active state and the focused node has no
779-
// renderer we can just ignore the state change.
780-
if (!renderer())
781-
return;
782-
783-
if (styleChangeType() < SubtreeStyleChange) {
784-
if (renderStyle()->affectedByFocus())
785-
setNeedsStyleRecalc(LocalStyleChange);
786-
}
787-
}
788-
789-
void ContainerNode::setFocus(bool received)
790-
{
791-
if (focused() == received)
792-
return;
793-
794-
Node::setFocus(received);
795-
796-
focusStateChanged();
797-
798-
if (renderer() || received)
799-
return;
800-
801-
setNeedsStyleRecalc(LocalStyleChange);
802-
}
803-
804758
void ContainerNode::setActive(bool down)
805759
{
806760
if (down == active())

sky/engine/core/dom/ContainerNode.h

-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ class ContainerNode : public Node {
9090
virtual void attach(const AttachContext& = AttachContext()) override;
9191
virtual void detach(const AttachContext& = AttachContext()) override;
9292
virtual LayoutRect boundingBox() const override final;
93-
virtual void setFocus(bool) override;
94-
void focusStateChanged();
9593
virtual void setActive(bool = true) override;
9694
virtual void setHovered(bool = true) override;
9795

sky/engine/core/dom/Document.cpp

-44
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
#include "sky/engine/core/inspector/InspectorCounters.h"
7474
#include "sky/engine/core/loader/FrameLoaderClient.h"
7575
#include "sky/engine/core/page/ChromeClient.h"
76-
#include "sky/engine/core/page/FocusController.h"
7776
#include "sky/engine/core/page/Page.h"
7877
#include "sky/engine/core/painting/PaintingTasks.h"
7978
#include "sky/engine/core/painting/Picture.h"
@@ -256,7 +255,6 @@ void Document::dispose()
256255

257256
// We must make sure not to be retaining any of our children through
258257
// these extra pointers or we will create a reference cycle.
259-
m_focusedElement = nullptr;
260258
m_hoverNode = nullptr;
261259
m_activeHoverElement = nullptr;
262260
m_userActionElements.documentDidRemoveLastRef();
@@ -771,11 +769,6 @@ void Document::updateLayout()
771769
frameView->layout();
772770
}
773771

774-
void Document::setNeedsFocusedElementCheck()
775-
{
776-
setNeedsStyleRecalc(LocalStyleChange);
777-
}
778-
779772
StyleResolver& Document::styleResolver() const
780773
{
781774
ASSERT(isActive());
@@ -811,7 +804,6 @@ void Document::detach(const AttachContext& context)
811804
m_scriptedAnimationController.clear();
812805

813806
m_hoverNode = nullptr;
814-
m_focusedElement = nullptr;
815807
m_activeHoverElement = nullptr;
816808

817809
m_renderView = 0;
@@ -1046,19 +1038,6 @@ void Document::setActiveHoverElement(PassRefPtr<Element> newActiveElement)
10461038
m_activeHoverElement = newActiveElement;
10471039
}
10481040

1049-
void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly)
1050-
{
1051-
if (!m_focusedElement)
1052-
return;
1053-
1054-
// We can't be focused if we're not in the document.
1055-
if (!node->inDocument())
1056-
return;
1057-
bool contains = node->contains(m_focusedElement.get());
1058-
if (contains && (m_focusedElement != node || !amongChildrenOnly))
1059-
setFocusedElement(nullptr);
1060-
}
1061-
10621041
void Document::hoveredNodeDetached(Node* node)
10631042
{
10641043
if (!m_hoverNode)
@@ -1087,11 +1066,6 @@ void Document::activeChainNodeDetached(Node* node)
10871066
m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement(activeNode) : 0;
10881067
}
10891068

1090-
bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedElement, FocusType type)
1091-
{
1092-
return false;
1093-
}
1094-
10951069
void Document::updateRangesAfterChildrenChanged(ContainerNode* container)
10961070
{
10971071
if (!m_ranges.isEmpty()) {
@@ -1454,24 +1428,6 @@ float Document::devicePixelRatio() const
14541428
return m_frame ? m_frame->devicePixelRatio() : 1.0;
14551429
}
14561430

1457-
Element* Document::activeElement() const
1458-
{
1459-
if (Element* element = treeScope().adjustedFocusedElement())
1460-
return element;
1461-
return nullptr;
1462-
}
1463-
1464-
bool Document::hasFocus() const
1465-
{
1466-
Page* page = this->page();
1467-
if (!page)
1468-
return false;
1469-
if (!page->focusController().isActive() || !page->focusController().isFocused())
1470-
return false;
1471-
Frame* focusedFrame = page->focusController().focusedFrame();
1472-
return focusedFrame && focusedFrame == frame();
1473-
}
1474-
14751431
Picture* Document::rootPicture() const
14761432
{
14771433
return m_picture.get();

sky/engine/core/dom/Document.h

-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "sky/engine/core/dom/UserActionElementSet.h"
3939
#include "sky/engine/core/inspector/ScriptCallStack.h"
4040
#include "sky/engine/core/loader/DocumentLoadTiming.h"
41-
#include "sky/engine/core/page/FocusType.h"
4241
#include "sky/engine/platform/Length.h"
4342
#include "sky/engine/platform/heap/Handle.h"
4443
#include "sky/engine/platform/weborigin/KURL.h"
@@ -126,10 +125,6 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme
126125

127126
SelectorQueryCache& selectorQueryCache();
128127

129-
// Focus Management.
130-
Element* activeElement() const;
131-
bool hasFocus() const;
132-
133128
AbstractModule* module() const { return m_module; }
134129
void setModule(AbstractModule* module) { m_module = module; }
135130

@@ -263,16 +258,12 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme
263258

264259
TextLinkColors& textLinkColors() { return m_textLinkColors; }
265260

266-
bool setFocusedElement(PassRefPtr<Element>, FocusType = FocusTypeNone);
267-
Element* focusedElement() const { return m_focusedElement.get(); }
268261
UserActionElementSet& userActionElements() { return m_userActionElements; }
269262
const UserActionElementSet& userActionElements() const { return m_userActionElements; }
270-
void setNeedsFocusedElementCheck();
271263

272264
void setActiveHoverElement(PassRefPtr<Element>);
273265
Element* activeHoverElement() const { return m_activeHoverElement.get(); }
274266

275-
void removeFocusedElementOfSubtree(Node*, bool amongChildrenOnly = false);
276267
void hoveredNodeDetached(Node*);
277268
void activeChainNodeDetached(Node*);
278269

@@ -493,7 +484,6 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme
493484

494485
RefPtr<CSSStyleSheet> m_elemSheet;
495486

496-
RefPtr<Element> m_focusedElement;
497487
RefPtr<Node> m_hoverNode;
498488
RefPtr<Element> m_activeHoverElement;
499489
UserActionElementSet m_userActionElements;

sky/engine/core/dom/Document.idl

-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,4 @@
5151
Range caretRangeFromPoint([Default=Undefined] optional long x,
5252
[Default=Undefined] optional long y);
5353

54-
// HTML 5
55-
readonly attribute Element activeElement;
56-
boolean hasFocus();
5754
};

0 commit comments

Comments
 (0)