[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/khtml
From:       Maks Orlovich <maksim () kde ! org>
Date:       2010-10-11 16:47:15
Message-ID: 20101011164715.DB6F0AC7E4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1184868 by orlovich:

Add HTMLDocument::activeElement. Got requested in a bug report, and it's in HTML5, \
too. Also cleanup completely redundant HTMLDocumentImpl::body() (which was \
identical(!)) to  DocumentImpl::body())

BUG: 253847
FIXED-IN: 4.5.3


 M  +4 -0      ecma/kjs_html.cpp  
 M  +1 -1      ecma/kjs_html.h  
 M  +9 -20     html/html_documentimpl.cpp  
 M  +3 -1      html/html_documentimpl.h  


--- trunk/KDE/kdelibs/khtml/ecma/kjs_html.cpp #1184867:1184868
@@ -187,6 +187,8 @@
   frames		HTMLDocument::Frames		DontDelete|ReadOnly
 #NS4 extension
   layers		HTMLDocument::Layers		DontDelete|ReadOnly
+# HTML5
+  activeElement         HTMLDocument::ActiveElement     DontDelete|ReadOnly
 #potentially obsolete array properties
 # plugins
 # tags
@@ -392,6 +394,8 @@
               == DocumentImpl::Compat ? "BackCompat" : "CSS1Compat");
     case DesignMode:
         return jsString((doc.designMode() ? "on":"off"));
+    case ActiveElement:
+	return getDOMNode(exec, doc.activeElement());
     case BgColor:
       return jsString(body ? body->getAttribute(ATTR_BGCOLOR) : DOMString());
     case FgColor:
--- trunk/KDE/kdelibs/khtml/ecma/kjs_html.h #1184867:1184868
@@ -53,7 +53,7 @@
            Images, Applets, Links, Forms, Layers, Anchors, Scripts, All, Clear, \
                Open, Close,
            Write, WriteLn, GetElementsByName, GetSelection, CaptureEvents, \
                ReleaseEvents,
            BgColor, FgColor, AlinkColor, LinkColor, VlinkColor, LastModified,
-           Height, Width, Dir, Frames, CompatMode, DesignMode };
+           Height, Width, Dir, Frames, CompatMode, DesignMode, ActiveElement };
     DOM::HTMLDocumentImpl* impl() const { return \
static_cast<DOM::HTMLDocumentImpl*>( m_impl.get() ); }  private:
     static JSValue *nameGetter(ExecState *exec, JSObject*, const Identifier& name, \
                const PropertySlot& slot);
--- trunk/KDE/kdelibs/khtml/html/html_documentimpl.cpp #1184867:1184868
@@ -131,26 +131,6 @@
                      URL().url(), fake_header, qlonglong(windowId));
 }
 
-
-
-HTMLElementImpl *HTMLDocumentImpl::body()
-{
-    NodeImpl *de = documentElement();
-    if (!de)
-        return 0;
-
-    // try to prefer a FRAMESET element over BODY
-    NodeImpl* body = 0;
-    for (NodeImpl* i = de->firstChild(); i; i = i->nextSibling()) {
-        if (i->id() == ID_FRAMESET)
-            return static_cast<HTMLElementImpl*>(i);
-
-        if (i->id() == ID_BODY)
-            body = i;
-    }
-    return static_cast<HTMLElementImpl *>(body);
-}
-
 void HTMLDocumentImpl::setBody(HTMLElementImpl *_body, int& exceptioncode)
 {
     HTMLElementImpl *b = body();
@@ -189,6 +169,15 @@
     return createHTMLElement(name, hMode != XHtml);
 }
 
+ElementImpl* HTMLDocumentImpl::activeElement() const
+{
+    NodeImpl* fn = focusNode();
+    if (!fn || !fn->isElementNode())
+	return body();
+    else
+	return static_cast<ElementImpl*>(fn);
+}
+
 void HTMLDocumentImpl::slotHistoryChanged()
 {
     if ( true || !m_render )
--- trunk/KDE/kdelibs/khtml/html/html_documentimpl.h #1184867:1184868
@@ -64,7 +64,6 @@
     HTMLCollectionImpl* all();
     HTMLCollectionImpl* scripts();
 
-    HTMLElementImpl *body();
     void setBody(HTMLElementImpl *_body, int& exceptioncode);
 
     virtual khtml::Tokenizer *createTokenizer();
@@ -73,6 +72,9 @@
 
     virtual ElementImpl *createElement ( const DOMString &tagName, int* \
pExceptioncode );  
+    // HTML5
+    ElementImpl* activeElement() const;
+
     HTMLMapElementImpl* getMap(const DOMString& url_);
 
     virtual void determineParseMode();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic