Thanks to visit codestin.com
Credit goes to github.com

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

Remove focus support from sky/engine/core/*. #162

Merged
merged 1 commit into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions sky/engine/core/core.gni
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,6 @@ sky_core_files = [
"loader/UniqueIdentifier.cpp",
"loader/UniqueIdentifier.h",
"page/ChromeClient.h",
"page/FocusController.cpp",
"page/FocusController.h",
"page/FocusType.h",
"page/Page.cpp",
"page/Page.h",
"painting/Canvas.cpp",
Expand Down
1 change: 0 additions & 1 deletion sky/engine/core/css/CSSSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ struct NameToPseudoStruct {
// This table should be kept sorted.
const static NameToPseudoStruct pseudoTypeMap[] = {
{"active", CSSSelector::PseudoActive},
{"focus", CSSSelector::PseudoFocus},
{"host", CSSSelector::PseudoHost},
{"host(", CSSSelector::PseudoHost},
{"hover", CSSSelector::PseudoHover},
Expand Down
3 changes: 1 addition & 2 deletions sky/engine/core/css/CSSSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace blink {
Tag, // Example: div
Id, // Example: #id
Class, // example: .class
PseudoClass, // Example: :focus
PseudoClass, // Example: :hover
PseudoElement, // Example: ::first-line
Exact, // Example: E[foo="bar"]
Set, // Example: E[foo]
Expand All @@ -112,7 +112,6 @@ namespace blink {
PseudoNotParsed = 0,
PseudoUnknown,
PseudoHover,
PseudoFocus,
PseudoActive,
PseudoLang,
PseudoHost,
Expand Down
3 changes: 0 additions & 3 deletions sky/engine/core/css/ElementRuleCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData)
if (checker.matchedAttributeSelector())
m_style->setUnique();

if (checker.matchedFocusSelector())
m_style->setAffectedByFocus();

if (checker.matchedHoverSelector())
m_style->setAffectedByHover();

Expand Down
16 changes: 0 additions & 16 deletions sky/engine/core/css/SelectorChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,13 @@
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/html/parser/HTMLParserIdioms.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/rendering/style/RenderStyle.h"

namespace blink {

static bool matchesFocusPseudoClass(const Element& element)
{
if (!element.focused())
return false;
LocalFrame* frame = element.document().frame();
if (!frame)
return false;
return true;
}

SelectorChecker::SelectorChecker(const Element& element)
: m_element(element)
, m_matchedAttributeSelector(false)
, m_matchedFocusSelector(false)
, m_matchedHoverSelector(false)
, m_matchedActiveSelector(false)
{
Expand Down Expand Up @@ -122,10 +110,6 @@ bool SelectorChecker::checkOne(const CSSSelector& selector)
bool SelectorChecker::checkPseudoClass(const CSSSelector& selector)
{
switch (selector.pseudoType()) {
case CSSSelector::PseudoFocus:
m_matchedFocusSelector = true;
return matchesFocusPseudoClass(m_element);

case CSSSelector::PseudoHover:
m_matchedHoverSelector = true;
return m_element.hovered();
Expand Down
2 changes: 0 additions & 2 deletions sky/engine/core/css/SelectorChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class SelectorChecker {
bool match(const CSSSelector&);

bool matchedAttributeSelector() const { return m_matchedAttributeSelector; }
bool matchedFocusSelector() const { return m_matchedFocusSelector; }
bool matchedHoverSelector() const { return m_matchedHoverSelector; }
bool matchedActiveSelector() const { return m_matchedActiveSelector; }

Expand All @@ -54,7 +53,6 @@ class SelectorChecker {

const Element& m_element;
bool m_matchedAttributeSelector;
bool m_matchedFocusSelector;
bool m_matchedHoverSelector;
bool m_matchedActiveSelector;
};
Expand Down
46 changes: 0 additions & 46 deletions sky/engine/core/dom/ContainerNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ PassRefPtr<Node> ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* re
if (targets.isEmpty())
return newChild;

// Must check this again beacuse focus events might run synchronously when
// removing children.
checkAcceptChildHierarchy(*newChild, 0, exceptionState);
if (exceptionState.had_exception())
return nullptr;
Expand Down Expand Up @@ -252,8 +250,6 @@ PassRefPtr<Node> ContainerNode::replaceChild(PassRefPtr<Node> newChild, PassRefP
if (exceptionState.had_exception())
return nullptr;

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

document().removeFocusedElementOfSubtree(child.get());

// Events fired when blurring currently focused node might have moved this
// child into a different parent.
if (child->parentNode() != this) {
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?");
return nullptr;
Expand Down Expand Up @@ -450,12 +442,6 @@ void ContainerNode::removeChildren()
willRemoveChildren();

{
// Exclude this node when looking for removed focusedElement since only
// children will be removed.
// This must be later than willRemoveChildren, which might change focus
// state of a child.
document().removeFocusedElementOfSubtree(this, true);

// Removing a node from a selection can cause widget updates.
document().nodeChildrenWillBeRemoved(*this);
}
Expand Down Expand Up @@ -512,8 +498,6 @@ PassRefPtr<Node> ContainerNode::appendChild(PassRefPtr<Node> newChild, Exception
if (targets.isEmpty())
return newChild;

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

// This is used by FrameSelection to denote when the active-state of the page has changed
// independent of the focused element changing.
void ContainerNode::focusStateChanged()
{
// If we're just changing the window's active state and the focused node has no
// renderer we can just ignore the state change.
if (!renderer())
return;

if (styleChangeType() < SubtreeStyleChange) {
if (renderStyle()->affectedByFocus())
setNeedsStyleRecalc(LocalStyleChange);
}
}

void ContainerNode::setFocus(bool received)
{
if (focused() == received)
return;

Node::setFocus(received);

focusStateChanged();

if (renderer() || received)
return;

setNeedsStyleRecalc(LocalStyleChange);
}

void ContainerNode::setActive(bool down)
{
if (down == active())
Expand Down
2 changes: 0 additions & 2 deletions sky/engine/core/dom/ContainerNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ class ContainerNode : public Node {
virtual void attach(const AttachContext& = AttachContext()) override;
virtual void detach(const AttachContext& = AttachContext()) override;
virtual LayoutRect boundingBox() const override final;
virtual void setFocus(bool) override;
void focusStateChanged();
virtual void setActive(bool = true) override;
virtual void setHovered(bool = true) override;

Expand Down
44 changes: 0 additions & 44 deletions sky/engine/core/dom/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
#include "sky/engine/core/inspector/InspectorCounters.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/page/Page.h"
#include "sky/engine/core/painting/PaintingTasks.h"
#include "sky/engine/core/painting/Picture.h"
Expand Down Expand Up @@ -256,7 +255,6 @@ void Document::dispose()

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

void Document::setNeedsFocusedElementCheck()
{
setNeedsStyleRecalc(LocalStyleChange);
}

StyleResolver& Document::styleResolver() const
{
ASSERT(isActive());
Expand Down Expand Up @@ -811,7 +804,6 @@ void Document::detach(const AttachContext& context)
m_scriptedAnimationController.clear();

m_hoverNode = nullptr;
m_focusedElement = nullptr;
m_activeHoverElement = nullptr;

m_renderView = 0;
Expand Down Expand Up @@ -1046,19 +1038,6 @@ void Document::setActiveHoverElement(PassRefPtr<Element> newActiveElement)
m_activeHoverElement = newActiveElement;
}

void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly)
{
if (!m_focusedElement)
return;

// We can't be focused if we're not in the document.
if (!node->inDocument())
return;
bool contains = node->contains(m_focusedElement.get());
if (contains && (m_focusedElement != node || !amongChildrenOnly))
setFocusedElement(nullptr);
}

void Document::hoveredNodeDetached(Node* node)
{
if (!m_hoverNode)
Expand Down Expand Up @@ -1087,11 +1066,6 @@ void Document::activeChainNodeDetached(Node* node)
m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement(activeNode) : 0;
}

bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedElement, FocusType type)
{
return false;
}

void Document::updateRangesAfterChildrenChanged(ContainerNode* container)
{
if (!m_ranges.isEmpty()) {
Expand Down Expand Up @@ -1454,24 +1428,6 @@ float Document::devicePixelRatio() const
return m_frame ? m_frame->devicePixelRatio() : 1.0;
}

Element* Document::activeElement() const
{
if (Element* element = treeScope().adjustedFocusedElement())
return element;
return nullptr;
}

bool Document::hasFocus() const
{
Page* page = this->page();
if (!page)
return false;
if (!page->focusController().isActive() || !page->focusController().isFocused())
return false;
Frame* focusedFrame = page->focusController().focusedFrame();
return focusedFrame && focusedFrame == frame();
}

Picture* Document::rootPicture() const
{
return m_picture.get();
Expand Down
10 changes: 0 additions & 10 deletions sky/engine/core/dom/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "sky/engine/core/dom/UserActionElementSet.h"
#include "sky/engine/core/inspector/ScriptCallStack.h"
#include "sky/engine/core/loader/DocumentLoadTiming.h"
#include "sky/engine/core/page/FocusType.h"
#include "sky/engine/platform/Length.h"
#include "sky/engine/platform/heap/Handle.h"
#include "sky/engine/platform/weborigin/KURL.h"
Expand Down Expand Up @@ -126,10 +125,6 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme

SelectorQueryCache& selectorQueryCache();

// Focus Management.
Element* activeElement() const;
bool hasFocus() const;

AbstractModule* module() const { return m_module; }
void setModule(AbstractModule* module) { m_module = module; }

Expand Down Expand Up @@ -263,16 +258,12 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme

TextLinkColors& textLinkColors() { return m_textLinkColors; }

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

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

void removeFocusedElementOfSubtree(Node*, bool amongChildrenOnly = false);
void hoveredNodeDetached(Node*);
void activeChainNodeDetached(Node*);

Expand Down Expand Up @@ -493,7 +484,6 @@ class Document : public ContainerNode, public TreeScope, public DocumentSuppleme

RefPtr<CSSStyleSheet> m_elemSheet;

RefPtr<Element> m_focusedElement;
RefPtr<Node> m_hoverNode;
RefPtr<Element> m_activeHoverElement;
UserActionElementSet m_userActionElements;
Expand Down
3 changes: 0 additions & 3 deletions sky/engine/core/dom/Document.idl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,4 @@
Range caretRangeFromPoint([Default=Undefined] optional long x,
[Default=Undefined] optional long y);

// HTML 5
readonly attribute Element activeElement;
boolean hasFocus();
};
Loading