Changeset 50233 in webkit


Ignore:
Timestamp:
Oct 28, 2009 1:14:13 PM (15 years ago)
Author:
hamaji@chromium.org
Message:

2009-10-27 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get counter values with layoutTestContoller
https://bugs.webkit.org/show_bug.cgi?id=30555

  • Api/qwebframe.cpp: (QWebFrame::counterValueForElementById): (QWebHitTestResult::frame):
  • Api/qwebframe.h:

2009-10-27 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get counter values with layoutTestContoller
https://bugs.webkit.org/show_bug.cgi?id=30555

  • webkit/webkitprivate.h:
  • webkit/webkitwebframe.cpp: (webkit_web_frame_counter_value_for_element_by_id):

2009-10-27 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get counter values with layoutTestContoller
https://bugs.webkit.org/show_bug.cgi?id=30555

  • Interfaces/IWebFramePrivate.idl:
  • WebFrame.cpp: (WebFrame::counterValueForElementById):
  • WebFrame.h:

2009-10-27 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get counter values with layoutTestContoller
https://bugs.webkit.org/show_bug.cgi?id=30555

Add counterValueForElement in WebFrame to call WebCore::counterValueForElement.

  • Misc/WebCoreStatistics.h:
  • Misc/WebCoreStatistics.mm: (-[WebFrame counterValueForElement:]):

2009-10-27 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get counter values with layoutTestContoller
https://bugs.webkit.org/show_bug.cgi?id=30555

Expose WebCore::counterValueForElement as a WebCore API.

  • WebCore.base.exp:
  • rendering/RenderTreeAsText.cpp: (WebCore::writeCounterValuesFromChildren): (WebCore::counterValueForElement):
  • rendering/RenderTreeAsText.h:

2009-10-27 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get counter values with layoutTestContoller
https://bugs.webkit.org/show_bug.cgi?id=30555

Convert two pixel tests to dumpAsText tests using counterValueForElementById.

  • fast/css/counters/t1204-increment-00-c-o-expected.txt: Added.
  • fast/css/counters/t1204-increment-00-c-o.html:
  • fast/css/counters/t1204-increment-01-c-o-expected.txt: Added.
  • fast/css/counters/t1204-increment-01-c-o.html:
  • platform/mac/fast/css/counters/t1204-increment-00-c-o-expected.checksum: Removed.
  • platform/mac/fast/css/counters/t1204-increment-00-c-o-expected.png: Removed.
  • platform/mac/fast/css/counters/t1204-increment-00-c-o-expected.txt: Removed.
  • platform/mac/fast/css/counters/t1204-increment-01-c-o-expected.checksum: Removed.
  • platform/mac/fast/css/counters/t1204-increment-01-c-o-expected.png: Removed.
  • platform/mac/fast/css/counters/t1204-increment-01-c-o-expected.txt: Removed.
  • platform/qt/fast/css/counters/t1204-increment-00-c-o-expected.txt: Removed.
  • platform/qt/fast/css/counters/t1204-increment-01-c-o-expected.txt: Removed.

2009-10-27 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Darin Adler.

Provide a way to get counter values with layoutTestContoller
https://bugs.webkit.org/show_bug.cgi?id=30555

Define layoutTestContoller.counterValueForElementById.

  • DumpRenderTree/LayoutTestController.cpp: (counterValueForElementByIdCallback): (LayoutTestController::staticFunctions):
  • DumpRenderTree/LayoutTestController.h:
  • DumpRenderTree/mac/LayoutTestControllerMac.mm: (LayoutTestController::counterValueForElementById):
Location:
trunk
Files:
2 added
8 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r50226 r50233  
     12009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get counter values with layoutTestContoller
     6        https://bugs.webkit.org/show_bug.cgi?id=30555
     7
     8        Convert two pixel tests to dumpAsText tests using counterValueForElementById.
     9
     10        * fast/css/counters/t1204-increment-00-c-o-expected.txt: Added.
     11        * fast/css/counters/t1204-increment-00-c-o.html:
     12        * fast/css/counters/t1204-increment-01-c-o-expected.txt: Added.
     13        * fast/css/counters/t1204-increment-01-c-o.html:
     14        * platform/mac/fast/css/counters/t1204-increment-00-c-o-expected.checksum: Removed.
     15        * platform/mac/fast/css/counters/t1204-increment-00-c-o-expected.png: Removed.
     16        * platform/mac/fast/css/counters/t1204-increment-00-c-o-expected.txt: Removed.
     17        * platform/mac/fast/css/counters/t1204-increment-01-c-o-expected.checksum: Removed.
     18        * platform/mac/fast/css/counters/t1204-increment-01-c-o-expected.png: Removed.
     19        * platform/mac/fast/css/counters/t1204-increment-01-c-o-expected.txt: Removed.
     20        * platform/qt/fast/css/counters/t1204-increment-00-c-o-expected.txt: Removed.
     21        * platform/qt/fast/css/counters/t1204-increment-01-c-o-expected.txt: Removed.
     22
    1232009-10-28  Alexey Proskuryakov  <ap@apple.com>
    224
  • trunk/LayoutTests/fast/css/counters/t1204-increment-00-c-o.html

    r49225 r50233  
    1010
    1111  </style>
     12  <script src="../../js/resources/js-test-pre.js"></script>
    1213  <script type="text/javascript">
    1314
    14   if (window.layoutTestController)
     15  if (window.layoutTestController) {
    1516      layoutTestController.waitUntilDone();
     17      layoutTestController.dumpAsText();
     18  }
    1619
    17   function run() {
     20  function checkCounterValuesBeforeChange()
     21  {
     22      debug('Before the dynamic change:');
     23      shouldBe("layoutTestController.counterValueForElementById('one')", "'1'");
     24      shouldBe("layoutTestController.counterValueForElementById('three')", "'2'");
     25      shouldBe("layoutTestController.counterValueForElementById('four')", "'3'");
     26  }
     27
     28  function checkCounterValuesAfterChange()
     29  {
     30      debug('After the dynamic change:');
     31      shouldBe("layoutTestController.counterValueForElementById('one')", "'1'");
     32      shouldBe("layoutTestController.counterValueForElementById('two')", "'2'");
     33      shouldBe("layoutTestController.counterValueForElementById('three')", "'3'");
     34      shouldBe("layoutTestController.counterValueForElementById('four')", "'4'");
     35
     36      debug('');
     37      debug('TEST COMPLETE');
     38      // Eliminate confusing messages (counter values won't be dumped by dumpAsText).
     39      var viewElement = document.getElementById("view");
     40      viewElement.parentNode.removeChild(viewElement);
     41      layoutTestController.notifyDone();
     42  }
     43
     44  function run()
     45  {
     46      if (window.layoutTestController)
     47          checkCounterValuesBeforeChange();
     48
    1849      var t = document.getElementById("test");
    1950      var s = document.createElement("span");
    2051      s.setAttribute("class", "increment");
     52      s.setAttribute("id", "two");
    2153      s.appendChild(document.createTextNode("new-"));
    2254      t.insertBefore(s, t.childNodes.item(1));
    2355
    2456      if (window.layoutTestController)
    25           layoutTestController.notifyDone();
     57          checkCounterValuesAfterChange();
    2658  }
    27 
    28   // We cannot use dumpAsText() because the counters are CSS properties and
    29   // they aren't dumped by the function. Let's use render tree...
    3059  </script>
    3160 </head>
    3261
    33  <!-- This test checks if the counters work properly when some elements are
    34  added/removed *after* the first rendering finishes. If we put the script in
    35  <body>, this only checks the results of first rendering and this isn't
    36  the purpose of this test. That's why we use timeout for this test. -->
    37  <body onload="setTimeout('run()', 0)">
     62 <body onload="run();">
    3863
     64 <p>This is the WebKit version of <a href="http://www.w3.org/Style/CSS/Test/CSS2.1/20061011/html4/t1204-increment-00-c-o.htm">CSS 2.1 Test Suite: dynamic changes to 'counter-increment'</a>.</p>
     65
     66 <div id="view">
    3967 <p>The following two lines should be the same:</p>
     68 <div id="test"><span id="one" class="increment"></span><span id="three" class="increment"></span><span id="four" class="increment"></span></div>
     69 <div id="reference">1-2-new-3-4-</div>
     70 </div>
    4071
    41  <div id="test"><span class="increment"></span><span class="increment"></span><span class="increment"></span></div>
    42 
    43  <div id="reference">1-2-new-3-4-</div>
     72 <div id="console"></div>
    4473
    4574 </body>
  • trunk/LayoutTests/fast/css/counters/t1204-increment-01-c-o.html

    r49225 r50233  
    1010
    1111  </style>
     12  <script src="../../js/resources/js-test-pre.js"></script>
    1213  <script type="text/javascript">
    1314
    14   if (window.layoutTestController)
     15  if (window.layoutTestController) {
    1516      layoutTestController.waitUntilDone();
     17      layoutTestController.dumpAsText();
     18  }
    1619
    17   function run() {
     20  function checkCounterValuesBeforeChange()
     21  {
     22      debug('Before the dynamic change:');
     23      shouldBe("layoutTestController.counterValueForElementById('one')", "'1'");
     24      shouldBe("layoutTestController.counterValueForElementById('two')", "'3'");
     25      shouldBe("layoutTestController.counterValueForElementById('three')", "'4'");
     26  }
     27
     28  function checkCounterValuesAfterChange()
     29  {
     30      debug('After the dynamic change:');
     31      shouldBe("layoutTestController.counterValueForElementById('one')", "'1'");
     32      shouldBe("layoutTestController.counterValueForElementById('two')", "'2'");
     33      shouldBe("layoutTestController.counterValueForElementById('three')", "'3'");
     34
     35      debug('');
     36      debug('TEST COMPLETE');
     37      // Eliminate confusing messages (counter values won't be dumped by dumpAsText).
     38      var viewElement = document.getElementById("view");
     39      viewElement.parentNode.removeChild(viewElement);
     40      layoutTestController.notifyDone();
     41  }
     42
     43  function run()
     44  {
     45      if (window.layoutTestController)
     46          checkCounterValuesBeforeChange();
     47
    1848      var t = document.getElementById("test");
    1949      t.removeChild(t.childNodes.item(1));
    2050
    2151      if (window.layoutTestController)
    22           layoutTestController.notifyDone();
     52          checkCounterValuesAfterChange();
    2353  }
    24 
    25   // We cannot use dumpAsText() because the counters are CSS properties and
    26   // they aren't dumped by the function. Let's use render tree...
    2754  </script>
    2855 </head>
    2956
    30  <!-- This test checks if the counters work properly when some elements are
    31  added/removed *after* the first rendering finishes. If we put the script in
    32  <body>, this only checks the results of first rendering and this isn't
    33  the purpose of this test. That's why we use timeout for this test. -->
    34  <body onload="setTimeout('run()', 0)">
     57 <body onload="run();">
    3558
     59 <p>This is the WebKit version of <a href="http://www.w3.org/Style/CSS/Test/CSS2.1/20061011/html4/t1204-increment-01-c-o.htm">CSS 2.1 Test Suite: dynamic changes to 'counter-increment'</a>.</p>
     60
     61 <div id="view">
    3662 <p>The following two lines should be the same:</p>
     63 <div id="test"><span id="one" class="increment"></span><span class="increment">FAIL-</span><span id="two" class="increment"></span><span id="three" class="increment"></span></div>
     64 <div id="reference">1-2-3-</div>
     65 </div>
    3766
    38  <div id="test"><span class="increment"></span><span class="increment">FAIL-</span><span class="increment"></span><span class="increment"></span></div>
    39 
    40  <div id="reference">1-2-3-</div>
     67 <div id="console"></div>
    4168
    4269 </body>
  • trunk/WebCore/ChangeLog

    r50231 r50233  
     12009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get counter values with layoutTestContoller
     6        https://bugs.webkit.org/show_bug.cgi?id=30555
     7
     8        Expose WebCore::counterValueForElement as a WebCore API.
     9
     10        * WebCore.base.exp:
     11        * rendering/RenderTreeAsText.cpp:
     12        (WebCore::writeCounterValuesFromChildren):
     13        (WebCore::counterValueForElement):
     14        * rendering/RenderTreeAsText.h:
     15
    1162009-10-28  Nate Chapin  <japhet@chromium.org>
    217
  • trunk/WebCore/WebCore.base.exp

    r50012 r50233  
    423423__ZN7WebCore22ScriptExecutionContext26canSuspendActiveDOMObjectsEv
    424424__ZN7WebCore22applicationIsAppleMailEv
     425__ZN7WebCore22counterValueForElementEPNS_7ElementE
    425426__ZN7WebCore22createFragmentFromTextEPNS_5RangeERKNS_6StringE
    426427__ZN7WebCore22externalRepresentationEPNS_12RenderObjectE
  • trunk/WebCore/rendering/RenderTreeAsText.cpp

    r46815 r50233  
    2929#include "CSSMutableStyleDeclaration.h"
    3030#include "CharacterNames.h"
     31#include "CString.h"
    3132#include "Document.h"
    3233#include "Frame.h"
     
    554555}
    555556
     557static void writeCounterValuesFromChildren(TextStream& stream, RenderObject* parent)
     558{
     559    for (RenderObject* child = parent->firstChild(); child; child = child->nextSibling()) {
     560        if (child->isCounter()) {
     561            String str(toRenderText(child)->text());
     562            stream << str;
     563        }
     564    }
     565}
     566
     567String counterValueForElement(Element* element)
     568{
     569    // Make sure the element is not freed during the layout.
     570    RefPtr<Element> elementRef(element);
     571    element->document()->updateLayout();
     572    TextStream stream;
     573    // The counter renderers should be children of anonymous children
     574    // (i.e., :before or :after pseudo-elements).
     575    if (RenderObject* renderer = element->renderer()) {
     576        for (RenderObject* child = renderer->firstChild(); child; child = child->nextSibling()) {
     577            if (child->isAnonymous())
     578                writeCounterValuesFromChildren(stream, child);
     579        }
     580    }
     581    return stream.release();
     582}
     583
    556584} // namespace WebCore
  • trunk/WebCore/rendering/RenderTreeAsText.h

    r30418 r50233  
    2929namespace WebCore {
    3030
    31     class RenderObject;
    32     class String;
    33     class TextStream;
     31class Element;
     32class RenderObject;
     33class String;
     34class TextStream;
    3435
    35     String externalRepresentation(RenderObject*);
    36     void write(TextStream&, const RenderObject&, int indent = 0);
     36String externalRepresentation(RenderObject*);
     37void write(TextStream&, const RenderObject&, int indent = 0);
    3738
    38     // Helper function shared with SVGRenderTreeAsText
    39     String quoteAndEscapeNonPrintables(const String&);
     39// Helper function shared with SVGRenderTreeAsText
     40String quoteAndEscapeNonPrintables(const String&);
     41
     42String counterValueForElement(Element*);
    4043
    4144} // namespace WebCore
  • trunk/WebKit/gtk/ChangeLog

    r50225 r50233  
     12009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get counter values with layoutTestContoller
     6        https://bugs.webkit.org/show_bug.cgi?id=30555
     7
     8        * webkit/webkitprivate.h:
     9        * webkit/webkitwebframe.cpp:
     10        (webkit_web_frame_counter_value_for_element_by_id):
     11
    1122009-10-28  Joe Mason  <jmason@rim.com>
    213
  • trunk/WebKit/gtk/webkit/webkitprivate.h

    r49168 r50233  
    286286    webkit_web_frame_dump_render_tree (WebKitWebFrame* frame);
    287287
     288    WEBKIT_API gchar*
     289    webkit_web_frame_counter_value_for_element_by_id (WebKitWebFrame* frame, const gchar* id);
     290
    288291    WEBKIT_API guint
    289292    webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame);
  • trunk/WebKit/gtk/webkit/webkitwebframe.cpp

    r49964 r50233  
    800800
    801801/**
     802 * webkit_web_frame_counter_value_for_element_by_id:
     803 * @frame: a #WebKitWebFrame
     804 * @id: an element ID string
     805 *
     806 * Return value: The counter value of element @id in @frame
     807 */
     808gchar* webkit_web_frame_counter_value_for_element_by_id(WebKitWebFrame* frame, const gchar* id)
     809{
     810    g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
     811
     812    Frame* coreFrame = core(frame);
     813    if (!coreFrame)
     814        return 0;
     815
     816    Element* coreElement = coreFrame->document()->getElementById(AtomicString(id));
     817    if (!coreElement)
     818        return 0;
     819    String counterValue = counterValueForElement(coreElement);
     820    return g_strdup(counterValue.utf8().data());
     821}
     822
     823/**
    802824 * webkit_web_frame_get_pending_unload_event_count:
    803825 * @frame: a #WebKitWebFrame
  • trunk/WebKit/mac/ChangeLog

    r50183 r50233  
     12009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get counter values with layoutTestContoller
     6        https://bugs.webkit.org/show_bug.cgi?id=30555
     7
     8        Add counterValueForElement in WebFrame to call WebCore::counterValueForElement.
     9
     10        * Misc/WebCoreStatistics.h:
     11        * Misc/WebCoreStatistics.mm:
     12        (-[WebFrame counterValueForElement:]):
     13
    1142009-10-27  Geoffrey Garen  <ggaren@apple.com>
    215
  • trunk/WebKit/mac/Misc/WebCoreStatistics.h

    r45923 r50233  
    3030
    3131#import <WebKit/WebFrame.h>
     32
     33@class DOMElement;
    3234
    3335@interface WebCoreStatistics : NSObject
     
    8284@interface WebFrame (WebKitDebug)
    8385- (NSString *)renderTreeAsExternalRepresentation;
     86- (NSString *)counterValueForElement:(DOMElement*)element;
    8487@end
  • trunk/WebKit/mac/Misc/WebCoreStatistics.mm

    r46431 r50233  
    2929#import "WebCoreStatistics.h"
    3030
     31#import "DOMElementInternal.h"
    3132#import "WebCache.h"
    3233#import "WebFrameInternal.h"
     
    245246}
    246247
     248- (NSString *)counterValueForElement:(DOMElement*)element
     249{
     250    return counterValueForElement(core(element));
     251}
     252
    247253@end
  • trunk/WebKit/qt/Api/qwebframe.cpp

    r50207 r50233  
    477477
    478478/*!
     479    Returns the value of counter in the element specified by \a id.
     480*/
     481QString QWebFrame::counterValueForElementById(const QString &id) const
     482{
     483    if (Document *document = d->frame->document()) {
     484        Element *element = document->getElementById(id);
     485        return WebCore::counterValueForElement(element);
     486    }
     487    return QString();
     488
     489}
     490
     491/*!
    479492    \property QWebFrame::title
    480493    \brief the title of the frame as defined by the HTML &lt;title&gt; element
     
    16871700    return d->frame;
    16881701}
    1689 
  • trunk/WebKit/qt/Api/qwebframe.h

    r50058 r50233  
    139139    QString toPlainText() const;
    140140    QString renderTreeDump() const;
     141    QString counterValueForElementById(const QString &id) const;
    141142
    142143    QString title() const;
  • trunk/WebKit/qt/ChangeLog

    r50224 r50233  
     12009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get counter values with layoutTestContoller
     6        https://bugs.webkit.org/show_bug.cgi?id=30555
     7
     8        * Api/qwebframe.cpp:
     9        (QWebFrame::counterValueForElementById):
     10        (QWebHitTestResult::frame):
     11        * Api/qwebframe.h:
     12
    1132009-10-28  Antonio Gomes  <tonikitoo@webkit.org>
    214
  • trunk/WebKit/win/ChangeLog

    r50225 r50233  
     12009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get counter values with layoutTestContoller
     6        https://bugs.webkit.org/show_bug.cgi?id=30555
     7
     8        * Interfaces/IWebFramePrivate.idl:
     9        * WebFrame.cpp:
     10        (WebFrame::counterValueForElementById):
     11        * WebFrame.h:
     12
    1132009-10-28  Joe Mason  <jmason@rim.com>
    214
  • trunk/WebKit/win/Interfaces/IWebFramePrivate.idl

    r50045 r50233  
    5858{
    5959    HRESULT renderTreeAsExternalRepresentation([out, retval] BSTR* result);
     60    HRESULT counterValueForElementById([in] BSTR id, [out, retval] BSTR* result);
    6061    HRESULT scrollOffset([out, retval] SIZE* offset);
    6162
  • trunk/WebKit/win/WebFrame.cpp

    r50227 r50233  
    825825}
    826826
     827HRESULT STDMETHODCALLTYPE WebFrame::counterValueForElementById(
     828    /* [in] */ BSTR id, /* [retval][out] */ BSTR *result)
     829{
     830    if (!result)
     831        return E_POINTER;
     832
     833    Frame* coreFrame = core(this);
     834    if (!coreFrame)
     835        return E_FAIL;
     836
     837    String coreId = String(id, SysStringLen(id));
     838
     839    Element* element = coreFrame->document()->getElementById(coreId);
     840    if (!element)
     841        return E_FAIL;
     842    *result = BString(counterValueForElement(element)).release();
     843    return S_OK;
     844}
     845
    827846HRESULT STDMETHODCALLTYPE WebFrame::scrollOffset(
    828847        /* [retval][out] */ SIZE* offset)
  • trunk/WebKit/win/WebFrame.h

    r50045 r50233  
    157157    // IWebFramePrivate
    158158    virtual HRESULT STDMETHODCALLTYPE renderTreeAsExternalRepresentation(
     159        /* [retval][out] */ BSTR *result);
     160
     161    virtual HRESULT STDMETHODCALLTYPE counterValueForElementById(
     162        /* [in] */ BSTR id,
    159163        /* [retval][out] */ BSTR *result);
    160164
  • trunk/WebKitTools/ChangeLog

    r50166 r50233  
     12009-10-27  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Provide a way to get counter values with layoutTestContoller
     6        https://bugs.webkit.org/show_bug.cgi?id=30555
     7
     8        Define layoutTestContoller.counterValueForElementById.
     9
     10        * DumpRenderTree/LayoutTestController.cpp:
     11        (counterValueForElementByIdCallback):
     12        (LayoutTestController::staticFunctions):
     13        * DumpRenderTree/LayoutTestController.h:
     14        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
     15        (LayoutTestController::counterValueForElementById):
     16
    1172009-10-27  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    218
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.cpp

    r49963 r50233  
    386386}
    387387
     388static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     389{
     390    if (argumentCount < 1)
     391        return JSValueMakeUndefined(context);
     392
     393    JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     394    if (*exception)
     395        return JSValueMakeUndefined(context);
     396
     397    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     398    JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
     399    if (!counterValue.get())
     400        return JSValueMakeUndefined(context);
     401    return JSValueMakeString(context, counterValue.get());
     402}
     403
    388404static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    389405{
     
    12021218        { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    12031219        { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1220        { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    12041221        { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    12051222        { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.h

    r49963 r50233  
    3131
    3232#include <JavaScriptCore/JSObjectRef.h>
     33#include <JavaScriptCore/JSRetainPtr.h>
    3334#include <wtf/RefCounted.h>
    3435#include <string>
     
    5253    void display();
    5354    void execCommand(JSStringRef name, JSStringRef value);
     55    JSRetainPtr<JSStringRef> counterValueForElementById(JSStringRef id);
    5456    bool isCommandEnabled(JSStringRef name);
    5557    void keepWebHistory();
  • trunk/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

    r49968 r50233  
    5353unsigned int webkit_worker_thread_count(void);
    5454void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains);
     55gchar* webkit_web_frame_counter_value_for_element_by_id(WebKitWebFrame* frame, const gchar* id);
    5556}
    5657
     
    117118{
    118119    displayWebView();
     120}
     121
     122JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id)
     123{
     124    gchar* idGChar = JSStringCopyUTF8CString(id);
     125    gchar* counterValueGChar = webkit_web_frame_counter_value_for_element_by_id(mainFrame, idGChar);
     126    g_free(idGChar);
     127    if (!counterValueGChar)
     128        return 0;
     129    JSRetainPtr<JSStringRef> counterValue(Adopt, JSStringCreateWithUTF8CString(counterValueGChar));
     130    return counterValue;
    119131}
    120132
  • trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm

    r49963 r50233  
    4343#import <WebKit/WebApplicationCache.h>
    4444#import <WebKit/WebBackForwardList.h>
     45#import <WebKit/WebCoreStatistics.h>
    4546#import <WebKit/WebDatabaseManagerPrivate.h>
    4647#import <WebKit/WebDataSource.h>
     
    152153}
    153154
     155JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id)
     156{
     157    RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, id));
     158    NSString *idNS = (NSString *)idCF.get();
     159
     160    DOMElement *element = [[mainFrame DOMDocument] getElementById:idNS];
     161    if (!element)
     162        return 0;
     163
     164    JSRetainPtr<JSStringRef> counterValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame counterValueForElement:element]));
     165    return counterValue;
     166}
     167
    154168void LayoutTestController::keepWebHistory()
    155169{
  • trunk/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp

    r50166 r50233  
    110110}
    111111
     112QString LayoutTestController::counterValueForElementById(const QString& id)
     113{
     114    return m_drt->webPage()->mainFrame()->counterValueForElementById(id);
     115}
     116
    112117void LayoutTestController::keepWebHistory()
    113118{
     
    309314        settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt());
    310315}
    311 
  • trunk/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h

    r49915 r50233  
    8484    void setCanOpenWindows() { m_canOpenWindows = true; }
    8585    void waitUntilDone();
     86    QString counterValueForElementById(const QString& id);
    8687    void keepWebHistory();
    8788    void notifyDone();
  • trunk/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp

    r49963 r50233  
    976976    sharedHistoryPrivate->removeAllVisitedLinks();
    977977}
     978
     979JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id)
     980{
     981    COMPtr<IWebFramePrivate> framePrivate(Query, frame);
     982    if (!framePrivate)
     983        return 0;
     984
     985    wstring idWstring = jsStringRefToWString(id);
     986    BSTR idBSTR = SysAllocStringLen((OLECHAR*)idWstring.c_str(), idWstring.length());
     987    BSTR counterValueBSTR;
     988    if (FAILED(framePrivate->counterValueForElementById(idBSTR, &counterValueBSTR)))
     989        return 0;
     990
     991    wstring counterValue(counterValueBSTR, SysStringLen(counterValueBSTR));
     992    SysFreeString(idBSTR);
     993    SysFreeString(counterValueBSTR);
     994    JSRetainPtr<JSStringRef> counterValueJS(Adopt, JSStringCreateWithCharacters(counterValue.data(), counterValue.length()));
     995    return counterValueJS;
     996}
     997
Note: See TracChangeset for help on using the changeset viewer.